? Success

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
16 Jan 2016

Description

This PR, to remove duplicate queries from db, it saves into variables the result of the db queries of the two methods moved, only running the db query if needed.

Also moves some multilanguage methods from com_languages helper MultilangstatusHelper to JLanguage Multilang helper JLanguageMultilang.

Performance

This adds a little performance benefit. Around 2ms to 3ms of total page generation time (in a PHP 5.6 installation).

Before

image

After

image

How to test

  1. Apply patch in a default Joomla install.
  2. Check if a multilanguage site is working properly (frontend mod_languages works, frontend language filter works and admin multilanguage status works)
  3. Check if language associations are working properly
  4. Enable the debug console and see there are less queries (check before/after PR) and less ms taken to do all database queries.

Observations

Since this PR adds and deprecates some class methods, please say if anything else is needed to do.
Suggestions, code reviews and improvements are welcome.

avatar andrepereiradasilva andrepereiradasilva - open - 16 Jan 2016
avatar andrepereiradasilva andrepereiradasilva - change - 16 Jan 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 16 Jan 2016
Labels Added: ?
avatar andrepereiradasilva andrepereiradasilva - change - 16 Jan 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - change - 16 Jan 2016
The description was changed
avatar infograf768
infograf768 - comment - 17 Jan 2016

I get some Notices and Warning when the item has no associations yet.

( ! ) Notice: Undefined index: com_content|#__content|com_content.item|213|id|alias|catid in /ROOT/libraries/cms/language/associations.php on line 121

or
( ! ) Notice: Undefined index: com_menus|#__menu|com_menus.item|631|id|| in ROOT/libraries/cms/language/associations.php on line 121

with for example
( ! ) Warning: Invalid argument supplied for foreach() in ROOT/trunkgitnew/administrator/components/com_menus/helpers/menus.php on line 321

I can get rid of the Warning for example in the menus helper by checking if we do have associations:

    public static function getAssociations($pk)
    {
        $langAssociations = JLanguageAssociations::getAssociations('com_menus', '#__menu', 'com_menus.item', $pk, 'id', '', '');
        $associations = array();

        if ($langAssociations)
        {
            foreach ($langAssociations as $langAssociation)
            {
                $associations[$langAssociation->language] = $langAssociation->id;
            }
        }

        return $associations;
    }

But I still have the Notice.
I could get rid of it by adding a conditional, but not sure it is the best way.

        if (!empty($multilanguageAssociations[$queryKey]))
        {
            return $multilanguageAssociations[$queryKey];
        }
avatar andrepereiradasilva
andrepereiradasilva - comment - 17 Jan 2016

sorry @infograf768 code was a problem, i willl fix it soon

avatar andrepereiradasilva
andrepereiradasilva - comment - 17 Jan 2016

i think it's solved now, the bug was is line 47 andrepereiradasilva@167035f#diff-5ca4c28b8e63fb73e99b5128c808630fR47 (the variable name was wrong)

avatar infograf768 infograf768 - test_item - 20 Jan 2016 - Tested successfully
avatar infograf768
infograf768 - comment - 20 Jan 2016

I have tested this item :white_check_mark: successfully on b9d67c2

Wow! This works real good here. Thanks for this PR.


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

avatar MATsxm MATsxm - test_item - 20 Jan 2016 - Tested successfully
avatar MATsxm
MATsxm - comment - 20 Jan 2016

I have tested this item :white_check_mark: successfully on b9d67c2

No problems here!
Thanks :+1:


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

avatar dgt41 dgt41 - test_item - 20 Jan 2016 - Tested successfully
avatar dgt41
dgt41 - comment - 20 Jan 2016

I have tested this item :white_check_mark: successfully on b9d67c2


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

avatar dgt41 dgt41 - change - 20 Jan 2016
Status Pending Ready to Commit
avatar dgt41
dgt41 - comment - 20 Jan 2016

RTC then!

avatar joomla-cms-bot joomla-cms-bot - change - 20 Jan 2016
Labels Added: ?
avatar wilsonge wilsonge - change - 21 Jan 2016
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2016-01-21 23:39:34
Closed_By wilsonge
avatar wilsonge wilsonge - close - 21 Jan 2016
avatar joomla-cms-bot joomla-cms-bot - close - 21 Jan 2016
avatar wilsonge wilsonge - close - 21 Jan 2016
avatar joomla-cms-bot joomla-cms-bot - change - 21 Jan 2016
Labels Removed: ?
avatar andrepereiradasilva andrepereiradasilva - head_ref_deleted - 22 Jan 2016

Add a Comment

Login with GitHub to post a comment