? Success

User tests: Successful: Unsuccessful:

avatar smz
smz
7 Jun 2015

Description

getAssociations() is called several times in the life of a Joomla! process.
This PR optimize it by locally caching the result

Testing procedure

  • Use a multilingual site with at least some menu items associated between themselves (menu item association) and with the "Add Alternate Meta Tags" set to "Yes" in the language filter
  • Navigate to a menu item associated to another menu item in a different language.
  • Switch back and forth from one language to another using the language switcher and verify that menu items association is respected
  • Verify in the generated HTML that the "rel="alternate" tags are present and correct
  • Turn on Joomla Debug in global configuration and verify that at least a couple of duplicated queries are now gone.

Even better: apply this together with #7136. If OK, you can give "@test OK" to both PRs

avatar smz smz - open - 7 Jun 2015
avatar smz smz - change - 7 Jun 2015
The description was changed
avatar smz
smz - comment - 7 Jun 2015

Please test this together with #7136

avatar smz smz - change - 7 Jun 2015
The description was changed
avatar dgt41
dgt41 - comment - 7 Jun 2015

@smz Great initiative! Can you provide the execution times before and after, so people can actually see the improvement here and in the other similar PR?

avatar smz
smz - comment - 7 Jun 2015

Well, TBH, it is just a matter of few ms gained, nothing to write home about, but anyway...

avatar dgt41
dgt41 - comment - 7 Jun 2015

Few ms here few ms there we end up with a great CMS :+1:

avatar smz
smz - comment - 7 Jun 2015

:smile:

avatar smz
smz - comment - 7 Jun 2015

... thinking about if we should/can move/add something like that at the DB driver level, taking into account the queries hash... Poor men's Memcached...

avatar zero-24 zero-24 - change - 7 Jun 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 7 Jun 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 7 Jun 2015
Category Multilanguage
avatar zero-24 zero-24 - change - 7 Jun 2015
Status New Pending
avatar smz smz - change - 7 Jun 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-06-07 23:50:34
Closed_By smz
avatar smz
smz - comment - 7 Jun 2015

This PR is a HUGE mistake! getAssociations() can be (and is) called with different primary keys, so we cannot just cache it like I did.

What a shame! :flushed:

avatar smz smz - close - 7 Jun 2015
avatar smz smz - close - 7 Jun 2015
avatar smz
smz - comment - 8 Jun 2015

OK, after all it can be done: as @wilsonge correctly suggests, there are good odds that this is called only with the ID of the current page.

So it may be worth to create a $cache array in which to store results for every $pk with which this is called and most of the times it will be an array of just one element...

Reopening and correcting.

avatar smz smz - change - 8 Jun 2015
Status Closed New
Closed_Date 2015-06-07 23:50:34
Closed_By smz
avatar smz smz - reopen - 8 Jun 2015
avatar smz smz - reopen - 8 Jun 2015
avatar infograf768
infograf768 - comment - 8 Jun 2015

Please specify in PR title and test instructions that this only concerns getAssociations() for menu items.

avatar smz smz - change - 8 Jun 2015
The description was changed
Title
Fixes duplicate queries from getAssociations()
Fixes duplicate queries from MenusHelper::getAssociations()
avatar smz smz - change - 8 Jun 2015
Title
Fixes duplicate queries from getAssociations()
Fixes duplicate queries from MenusHelper::getAssociations()
avatar smz
smz - comment - 8 Jun 2015

@infograf768 done! :smile:

avatar smz
smz - comment - 8 Jun 2015

@wilsonge and @mbabker, is it better that I get rid of the try/catch here too?

avatar zero-24 zero-24 - change - 9 Jun 2015
Status New Pending
avatar smz smz - change - 13 Jul 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-07-13 08:09:15
Closed_By smz
avatar smz smz - close - 13 Jul 2015

Add a Comment

Login with GitHub to post a comment