Skip to content

remove duplicated queries#19682

Closed
alikon wants to merge 8 commits intojoomla:stagingfrom
alikon:patch-101
Closed

remove duplicated queries#19682
alikon wants to merge 8 commits intojoomla:stagingfrom
alikon:patch-101

Conversation

@alikon
Copy link
Copy Markdown
Contributor

@alikon alikon commented Feb 14, 2018

Summary of Changes

the same query is executed once

Testing Instructions

Expected result

no duplicated queries

Actual result

duplicate queries one of them is this one

screenshot from 2018-02-14 21-04-06

->where('access IN (' . $groups . ')')
->where($db->qn('id') . ' = ' . (int) $assocId);
->where($db->qn('id') . ' IN (' . $catId . ')')
->where($db->qn('published') . ' = 1')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove extra space after =

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

$assocId = $arrId[0];
}

$catId = implode(',', $assocId);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove extra spaces before =

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@ethernidee
Copy link
Copy Markdown
Contributor

What do you think about renaming $filters to something like $cachedAssociations? Perhaps, it will be clearer, what is stored inside.

FILE: ...omla-cms/administrator/components/com_categories/helpers/categories.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
140 | ERROR | Space before closing parenthesis of function call prohibited

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Feb 17, 2018

from my personal pov is explained in declaration Cached array of the category item id.
but if you feel that renaming is better .... the pr branch is public....

{
// Include only published categories with user access
$arrId = explode(':', $langAssociation->id);
$assocId = $arrId[0];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn’t $assocId being reassigned each time and not array as to be expected?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right, fixed

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Mar 9, 2018

The return values are different.

Before PR:

array(2) {
  ["fr-FR"]=>
  string(18) "11:categorie-fr-fr"
  ["es-ES"]=>
  string(18) "12:categoria-es-es"
}

After PR:

array(2) {
  ["fr-FR"]=>
  string(2) "11"
  ["es-ES"]=>
  string(2) "12"
}

@ladyjer
Copy link
Copy Markdown
Contributor

ladyjer commented Apr 5, 2018

I have tested this item ✅ successfully on 7d724e0


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

Quy and others added 2 commits April 21, 2018 13:28
@ghost
Copy link
Copy Markdown

ghost commented Apr 27, 2018

@ladyjer can you please retest?

@infograf768
Copy link
Copy Markdown
Member

Notice: Undefined variable: assocId in /Applications/MAMP/htdocs/installmulti/trunkgitnew/administrator/components/com_categories/helpers/categories.php on line 135

Warning: implode(): Invalid arguments passed in /Applications/MAMP/htdocs/installmulti/trunkgitnew/administrator/components/com_categories/helpers/categories.php on line 135

1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND published = 1 AND access IN (1,1,5)' at line 3

$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());

// No assocations
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.

No associations

@infograf768
Copy link
Copy Markdown
Member

Test instructions should be updated.
This PR (after last correction) is checking duplicate queries of associated categories, NOT category menu items.
We can indeed associate category menu items without ever associating the categories concerned.

Therefore, to test, one should not associate the menu items, only the categories concerned.

Needs totally new tests.

@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented Apr 28, 2018

updated

Needs totally new tests.

👍

@Quy
Copy link
Copy Markdown
Contributor

Quy commented May 6, 2018

I have tested this item ✅ successfully on 2d30362


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

@csthomas
Copy link
Copy Markdown
Contributor

csthomas commented May 8, 2018

@alikon Are you sure we need static::$filters at all?

Before, the sql query was executed inside a loop, now it is executed outside. I have not yet tested it.

@viocassel
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on 2d30362


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

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Feb 3, 2019

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Feb 3, 2019
@ghost ghost added the J3 Issue label Apr 5, 2019
@ghost ghost removed the J3 Issue label Apr 19, 2019
@ghost ghost changed the title [com_categories][Multilanguage] - remove duplicated queries remove duplicated queries Apr 19, 2019
@alikon
Copy link
Copy Markdown
Contributor Author

alikon commented May 2, 2019

@HLeithner please a final response

1 year old rtc pr

@HLeithner
Copy link
Copy Markdown
Member

@alikon thx for you work but this is an optimization that should go into j4 and not in j3 because it doesn't fix a bug...

If this query still exists in j4 it would be great if you could rebase this pr to 4.0-dev

ymmv

@HLeithner HLeithner closed this May 10, 2019
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label May 10, 2019
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.

9 participants