? Pending

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
23 Apr 2017

Summary of Changes

It is possible to get separate JCategories objects based on the casing of the $extension parameter you pass to JCategories::getInstance(). This will result in running extra database queries because the internal cache doesn't persist across instances. The side effect of this is most notable in an internationalized website when the language module generates routes for the different languages, with the 3.7 code you will get duplicate database queries at least with com_content because one part of the router passes $extension = 'Content' and another part passes $extension = 'content'.

Testing Instructions

Prior to the patch being applied, enable debug mode and add this code snippet to your template:

// Replace ID 2 with a valid category ID on your site if necessary
JCategories::getInstance('Content')->get(2);
JCategories::getInstance('content')->get(2);

Without the patch, in your database queries section of the debug output, you should have duplicate queries coming from the JCategories::_load() method. After applying the patch, the duplicate query should go away.

Expected result

A single singleton instance of a JCategories object after normalizing the parameters

Actual result

A separate JCategories instance for an extension based on the casing of the extension name provided to the getInstance() method.

Documentation Changes Required

If someone is really relying on the casing to get "fresh" instances, this won't work anymore. But this is really such an edge case and unexpected behavior that if you're relying on this broken logic, you've got other issues to address in your code.

avatar mbabker mbabker - open - 23 Apr 2017
avatar mbabker mbabker - change - 23 Apr 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 23 Apr 2017
Category Libraries Unit Tests
avatar alikon
alikon - comment - 24 Apr 2017

I have tested this item successfully on ce1f3f2


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

avatar alikon alikon - test_item - 24 Apr 2017 - Tested successfully
avatar zero-24
zero-24 - comment - 24 Apr 2017

I have tested this item successfully on ce1f3f2

? I have just navigated to the frontend too. Looks good.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15493.
avatar zero-24 zero-24 - test_item - 24 Apr 2017 - Tested successfully
avatar infograf768 infograf768 - test_item - 24 Apr 2017 - Tested successfully
avatar infograf768
infograf768 - comment - 24 Apr 2017

I have tested this item successfully on ce1f3f2


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

avatar zero-24 zero-24 - change - 24 Apr 2017
Status Pending Ready to Commit
Labels Added: ? ?
avatar zero-24
zero-24 - comment - 24 Apr 2017

RTC. Thanks for testing!


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

avatar infograf768 infograf768 - change - 24 Apr 2017
Milestone Added:
avatar infograf768
infograf768 - comment - 24 Apr 2017

RTC. Good to go.


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

avatar wilsonge wilsonge - change - 24 Apr 2017
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-04-24 08:15:54
Closed_By wilsonge
Labels Removed: ?
avatar wilsonge wilsonge - close - 24 Apr 2017
avatar wilsonge wilsonge - merge - 24 Apr 2017

Add a Comment

Login with GitHub to post a comment