User tests: Successful: Unsuccessful:
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'
.
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.
A single singleton instance of a JCategories
object after normalizing the parameters
A separate JCategories
instance for an extension based on the casing of the extension name provided to the getInstance()
method.
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.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries Unit Tests |
I have tested this item
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
Labels |
Added:
?
?
|
RTC. Thanks for testing!
Milestone |
Added: |
RTC. Good to go.
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:
?
|
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.