Skip to content

remove deprecated method#32356

Merged
bembelimen merged 4 commits intojoomla:stagingfrom
rdeutz:cleaup_isAdmin_use
Mar 9, 2021
Merged

remove deprecated method#32356
bembelimen merged 4 commits intojoomla:stagingfrom
rdeutz:cleaup_isAdmin_use

Conversation

@rdeutz
Copy link
Copy Markdown
Contributor

@rdeutz rdeutz commented Feb 8, 2021

Summary of Changes

Remove deprecated isAdmin and getCfg calls in core

Testing Instructions

actions logs should work as before

@@ -716,7 +716,7 @@ public function __construct($config = array())

if (method_exists($app, 'getCfg'))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change this, too? Or shall we leave it as it is since that method still exists, it's just deprecated?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I'm not sure if an if (method_exists($app, 'get')) really makes sense.

Copy link
Copy Markdown
Member

@richard67 richard67 Feb 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all possible kinds of applications ($app) have a get method, we can replace the complete if then else here with this one line:

$default_limit = $app->get('list_limit', 20);

If not and we have to keep the method_exists, we should change that to method_exists($app, 'get'), and also in this case we should use a default of 20 for the get call.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fedik What do you think? Do we need an if (method_exists($app, 'get'))?

Copy link
Copy Markdown
Member

@Fedik Fedik Feb 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not need, because every joomla application extends Joomla\Application\AbstractApplication that have get()/set() method

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems I'm wrong with my suggestion to use $app->get('list_limit', 20), see reaction on my suggestion below. So forget that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggestion is good, but it need to replace whole if/else section, not just 1 line 😉

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that’s what I had in mind, so I tried to describe it here. Because there was already this code review comment, GitHub did not allow me to add another suggestion here. I‘d have to close this one here before, and then the discussion would be hidden, that’s why I asked first.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I still can't make a code suggestion to replace that if then else, because the end of the else is too far away from code changed by this PR, so I can't mark the code for suggestion so far down.

I think the complete

$app = JFactory::getApplication();

if (method_exists($app, 'getCfg'))
{
	$default_limit = $app->get('list_limit');
}
else
{
	$default_limit = 20;
}

can be replaced by

$default_limit = JFactory::getApplication()->get('list_limit', 20);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a PR to suggest the change: rdeutz#15

@toivo
Copy link
Copy Markdown
Contributor

toivo commented Feb 11, 2021

I have tested this item ✅ successfully on 67c09b2

Tested successfully in 3.9.25-dev of 11 February in Wampserver 3.2.4 using PHP 8.0.1.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32356.

…se-mod-1

Simplify code since every Joomla app has a get method
@bembelimen
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on 9b6eabc


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32356.

@chmst
Copy link
Copy Markdown
Contributor

chmst commented Mar 1, 2021

I have tested this item ✅ successfully on 9b6eabc

on Code review of changes, as there were aleady good tests


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32356.

@richard67
Copy link
Copy Markdown
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32356.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Mar 1, 2021
@rdeutz rdeutz added this to the Joomla! 3.9.26 milestone Mar 9, 2021
@bembelimen bembelimen merged commit 2077e37 into joomla:staging Mar 9, 2021
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Mar 9, 2021
@rdeutz rdeutz deleted the cleaup_isAdmin_use branch March 15, 2021 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants