Feature PR-5.0-dev PR-5.1-dev Pending

User tests: Successful: Unsuccessful:

avatar Denitz
Denitz
11 Nov 2022

Summary of Changes

Load language associations for multiple articles and categories in a single query per each ArticlesModel::getItems() call.

These methods now can accept array of IDs and return results grouped by ID in this case.
If a single int is provided as ID, the results are returned as they were before, full BC.

CategoriesHelper::getAssociations()
CategoryAssociationHelper::getCategoryAssociations()
AssociationHelper::getAssociations()
Associations::getAssociations

Also, CategoriesHelper::getAssociations() is optimized and an extra query for each loaded category is removed by using $advClause param of Associations::getAssociations().

ArticlesModel::getItems() now collects the article IDs to load the assocations for, next loads all associations in the single query.
Similar to I have already done with tags load.

Testing Instructions

  1. Install 5.0-beta2-dev
  2. Install German language
  3. Install Sample multingual data
  4. Clone each English article "Article (en-gb)" (edit it and click Save As Copy 2 times), we have 3 en-GB articles now.
  5. Clone each German article"Beitrag (de-de)" (edit it and click Save As Copy 2 times, we have 3 de-DE articles now.
  6. Edit 2nd and 3rd copies of articles and associate them. Now we have 3 en-GB articles asociated with 3 de-DE articles.
  7. Enable Joomla debug
  8. Enable "Associations" in com_content options (they can be enabled in homepage menu item settings but it doesn't work for some reason, looks like another issuse, hence we need to enable display of associations globally).
  9. Load frontend, see list of articles from a category with 37 SQL queries executed in debug bar, for each articles we load associated article in a separate query.
  10. Apply patch, see a single query which loads associated articles for all displayed articles.

Actual result BEFORE applying this Pull Request

37 queries in total, see a separate SQL query for each displayed article, like:

SELECT `c2`.`language`,CONCAT_WS(':', `c2`.`id`, `c2`.`alias`) AS `id`,CONCAT_WS(':', `ca`.`id`, `ca`.`alias`) AS `catid`
FROM `jos_content` AS `c`
INNER JOIN `jos_associations` AS `a` ON `a`.`id` = `c`.`id` AND `a`.`context` = :context
INNER JOIN `jos_associations` AS `a2` ON `a`.`key` = `a2`.`key`
INNER JOIN `jos_content` AS `c2` ON `a2`.`id` = `c2`.`id`
INNER JOIN `jos_categories` AS `ca` ON `c2`.`catid` = `ca`.`id` AND `ca`.`extension` = :extension2
...

Expected result AFTER applying this Pull Request

34 queries in total, see a single query per each ArticlesModel::getItems() call.

A new single query is like:

SELECT `c2`.`language`,`c`.`id` AS `pk`,CONCAT_WS(':', `c2`.`id`, `c2`.`alias`) AS `id`,CONCAT_WS(':', `ca`.`id`, `ca`.`alias`) AS `catid`
FROM `jos_content` AS `c`
INNER JOIN `jos_associations` AS `a` ON `a`.`id` = `c`.`id` AND `a`.`context` = :context
INNER JOIN `jos_associations` AS `a2` ON `a`.`key` = `a2`.`key`
INNER JOIN `jos_content` AS `c2` ON `a2`.`id` = `c2`.`id`
INNER JOIN `jos_categories` AS `ca` ON `c2`.`catid` = `ca`.`id` AND `ca`.`extension` = :extension2
...

Link to documentations

No documentation changes for docs.joomla.org needed
No documentation changes for manual.joomla.org needed

4f5160a 11 Nov 2022 avatar Denitz start
avatar Denitz Denitz - open - 11 Nov 2022
avatar Denitz Denitz - change - 11 Nov 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 11 Nov 2022
Category Administration com_categories Front End com_content Libraries
avatar richard67
richard67 - comment - 11 Nov 2022

I don't see it as a bug fix but as an improvement, so it should be made for the 4.3-dev branch and not the 4.2-dev branch.

avatar Denitz
Denitz - comment - 11 Nov 2022

@richard67 Sorry, rebased.

avatar richard67
richard67 - comment - 11 Nov 2022

Thanks.

avatar richard67 richard67 - change - 11 Nov 2022
Build 4.2-dev 4.3-dev
avatar richard67 richard67 - change - 11 Nov 2022
Labels Added: PR-4.3-dev
avatar HLeithner
HLeithner - comment - 8 May 2023

This pull request has been automatically rebased to 5.0-dev. No new features will be merged into Joomla! 4.3 series. Joomla! 4.4 series is a bridge release to make migration from Joomla! 4 to 5 as smooth as possible.

avatar Denitz Denitz - change - 23 Aug 2023
Labels Added: Feature PR-5.0-dev
Removed: PR-4.3-dev
avatar ceford
ceford - comment - 15 Sep 2023

This does not work for me - perhaps I have misunderstood the instructions. I selected the testing data All Frontend Views / Content Component / Article Category List. The debug queries show there are 10 Select calls as shown above both with and without the patch applied (my list length). With the patch applied there are 50 queries in total, without the patch there are 49.


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

8264cb5 16 Sep 2023 avatar Denitz fix
avatar Denitz Denitz - change - 16 Sep 2023
The description was changed
avatar Denitz Denitz - edited - 16 Sep 2023
avatar Denitz
Denitz - comment - 16 Sep 2023

@ceford Sorry, I've updated the test instructions for 5.0.0-bet2-dev, we need to enable display of associated articles.

avatar ceford ceford - test_item - 18 Sep 2023 - Tested successfully
avatar ceford
ceford - comment - 18 Sep 2023

I have tested this item ✅ successfully on f8faf01

I left my Testing data installed before installing Multilingual Sample data. Using a Category Blog for the Language specific articles I saw the query count go down from 47 to 43. There were no problems switching language or accessing the already installed English only menu items.


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

avatar richard67
richard67 - comment - 18 Sep 2023

@Denitz Could you fix the scss-cs error reported by Drone here? https://ci.joomla.org/joomla/joomla-cms/70244/1/16

build/media_source/templates/administrator/atum/scss/blocks/_quickicons.scss
133:11 ✖ Expected nesting depth to be no more than 4 max-nesting-depth

Thanks in advance.

avatar joomla-cms-bot joomla-cms-bot - change - 18 Sep 2023
Category Administration com_categories Front End com_content Libraries Administration com_categories Repository NPM Change Front End com_content Libraries
avatar Denitz
Denitz - comment - 18 Sep 2023

@richard67 It's strange because I didn't modify this file. Anyway, I've updated the current version from current 5.0-dev

avatar joomla-cms-bot joomla-cms-bot - change - 18 Sep 2023
Category Administration com_categories Front End com_content Libraries Repository NPM Change Administration com_categories Front End com_content Libraries
avatar Denitz Denitz - change - 18 Sep 2023
Labels Added: NPM Resource Changed
avatar richard67 richard67 - alter_testresult - 18 Sep 2023 - ceford: Tested successfully
avatar Denitz Denitz - change - 23 Sep 2023
Title
Multiload of article associations
[5.0] Multiload of article associations
avatar Denitz Denitz - edited - 23 Sep 2023
avatar HLeithner
HLeithner - comment - 30 Sep 2023

This pull request has been automatically rebased to 5.1-dev.

avatar Denitz Denitz - change - 3 Oct 2023
Title
[5.0] Multiload of article associations
[5.1] Multiload of article associations
avatar Denitz Denitz - edited - 3 Oct 2023
avatar fgsw fgsw - test_item - 1 Dec 2023 - Tested successfully
avatar fgsw
fgsw - comment - 1 Dec 2023

I have tested this item ✅ successfully on 292a79c


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

avatar richard67 richard67 - change - 24 Feb 2024
Labels Added: PR-5.1-dev
Removed: NPM Resource Changed
avatar richard67 richard67 - alter_testresult - 24 Feb 2024 - fgsw: Tested successfully
avatar Nuyonuyonoina
Nuyonuyonoina - comment - 24 Feb 2024

Tested successfully

avatar richard67
richard67 - comment - 24 Feb 2024

Tested successfully

@Nuyonuyonoina Please submit your result in the issue tracker https://issues.joomla.org/tracker/joomla-cms/39189 by using the blue "Test this" button, otherwise it is not counted. Just a comment is not sufficient.

avatar Hackwar
Hackwar - comment - 26 Feb 2024

I'm sorry to bother you with this again @Denitz, but could you fix the codestyle issues in this PR?

avatar Denitz
Denitz - comment - 29 Feb 2024

@Hackwar updated

avatar HLeithner
HLeithner - comment - 24 Apr 2024

This pull request has been automatically rebased to 5.2-dev.

avatar HLeithner HLeithner - change - 24 Apr 2024
Title
[5.1] Multiload of article associations
[5.2] Multiload of article associations
avatar HLeithner HLeithner - edited - 24 Apr 2024
avatar Hackwar
Hackwar - comment - 24 Jul 2024

@fgsw @Nuyonuyonoina Can you test this again?

avatar HLeithner
HLeithner - comment - 2 Sep 2024

This pull request has been automatically rebased to 5.3-dev.

avatar HLeithner HLeithner - change - 2 Sep 2024
Title
[5.2] Multiload of article associations
[5.3] Multiload of article associations
avatar HLeithner HLeithner - edited - 2 Sep 2024
avatar fgsw fgsw - test_item - 4 Sep 2024 - Tested successfully
avatar fgsw
fgsw - comment - 4 Sep 2024

I have tested this item ✅ successfully on ee1851d


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

Add a Comment

Login with GitHub to post a comment