Feature PR-6.1-dev PR-6.2-dev Pending

User tests: Successful: Unsuccessful:

avatar Denitz
Denitz
12 Sep 2025

Summary of Changes

Subsequent calls to $componentObject->getCategory() produce the same SQL query.

Testing Instructions

Add custom fields for articles, limit fields to category "Any Category".
Add fields values for articles from this category.
Show articles from this category in frontend, i.e. via Category Blog and show custom field values.

Actual result BEFORE applying this Pull Request

See multiple SQL query duplicates with the same params like:

SELECT `c`.`id`,`c`.`asset_id`,`c`.`access`,`c`.`alias`,`c`.`checked_out`,`c`.`checked_out_time`,`c`.`created_time`,`c`.`created_user_id`,`c`.`description`,`c`.`extension`,`c`.`hits`,`c`.`language`,`c`.`level`,`c`.`lft`,`c`.`metadata`,`c`.`metadesc`,`c`.`metakey`,`c`.`modified_time`,`c`.`note`,`c`.`params`,`c`.`parent_id`,`c`.`path`,`c`.`published`,`c`.`rgt`,`c`.`title`,`c`.`modified_user_id`,`c`.`version`, CASE WHEN CHAR_LENGTH(`c`.`alias`) != 0 THEN CONCAT_WS(':', `c`.`id`, `c`.`alias`) ELSE `c`.`id` END as `slug`
FROM `jos_categories` AS `s`
INNER JOIN `jos_categories` AS `c` ON (`s`.`lft` < `c`.`lft` AND `c`.`lft` < `s`.`rgt` AND `c`.`language` IN (:preparedArray3,:preparedArray4)) OR (`c`.`lft` <= `s`.`lft` AND `s`.`rgt` <= `c`.`rgt`)
WHERE (`c`.`extension` = :extension OR `c`.`extension` = 'system') AND `c`.`access` IN (:preparedArray1,:preparedArray2) AND `c`.`published` = 1 AND `s`.`id` = :id
ORDER BY `c`.`lft`

Expected result AFTER applying this Pull Request

Only single query with the same params.

Link to documentations

Please select:

  • No documentation changes for docs.joomla.org needed
  • No documentation changes for manual.joomla.org needed
avatar Denitz Denitz - open - 12 Sep 2025
avatar Denitz Denitz - change - 12 Sep 2025
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 12 Sep 2025
Category Libraries
e4a1920 12 Sep 2025 avatar Denitz CS
avatar Denitz Denitz - change - 12 Sep 2025
Labels Added: PR-5.3-dev
avatar ceford
ceford - comment - 18 Sep 2025

Not sure about this. With the patch applied I see the number of queries decrease by 1 but the query quoted above is still duplicated. Without the patch there are 3 instances, with the patch there are two instancies.

SELECT `c`.`id`,`c`.`asset_id`,`c`.`access`,`c`.`alias`,`c`.`checked_out`,`c`.`checked_out_time`,`c`.`created_time`,`c`.`created_user_id`,`c`.`description`,`c`.`extension`,`c`.`hits`,`c`.`language`,`c`.`level`,`c`.`lft`,`c`.`metadata`,`c`.`metadesc`,`c`.`metakey`,`c`.`modified_time`,`c`.`note`,`c`.`params`,`c`.`parent_id`,`c`.`path`,`c`.`published`,`c`.`rgt`,`c`.`title`,`c`.`modified_user_id`,`c`.`version`, CASE WHEN CHAR_LENGTH(`c`.`alias`) != 0 THEN CONCAT_WS(':', `c`.`id`, `c`.`alias`) ELSE `c`.`id` END as `slug`
FROM `kxq29_categories` AS `s`
INNER JOIN `kxq29_categories` AS `c` ON (`s`.`lft` < `c`.`lft` AND `c`.`lft` < `s`.`rgt` AND `c`.`language` IN (:preparedArray3,:preparedArray4)) OR (`c`.`lft` <= `s`.`lft` AND `s`.`rgt` <= `c`.`rgt`)
WHERE (`c`.`extension` = :extension OR `c`.`extension` = 'system') AND `c`.`access` IN (:preparedArray1,:preparedArray2) AND `c`.`published` = 1 AND `s`.`id` = :id
ORDER BY `c`.`lft`
```<hr /><sub>This comment was created with the <a href="https://github.com/joomla/jissues">J!Tracker Application</a> at <a href="https://issues.joomla.org/tracker/joomla-cms/46084">issues.joomla.org/tracker/joomla-cms/46084</a>.</sub>
avatar laoneo
laoneo - comment - 18 Sep 2025

Instead of modifying the existing one, I would create a new one. Like that you don't risk bc breaks.

avatar HLeithner
HLeithner - comment - 15 Oct 2025

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

avatar HLeithner
HLeithner - comment - 15 Oct 2025

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

avatar Denitz Denitz - change - 30 Oct 2025
Title
Static cache for CategoryServiceTrait
[6.1] Static cache for CategoryServiceTrait
avatar Denitz Denitz - edited - 30 Oct 2025
avatar Denitz Denitz - change - 30 Oct 2025
Labels Added: Feature PR-6.1-dev
avatar HLeithner
HLeithner - comment - 17 Mar 2026

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

avatar HLeithner HLeithner - change - 17 Mar 2026
Title
[6.1] Static cache for CategoryServiceTrait
[6.2] Static cache for CategoryServiceTrait
avatar HLeithner HLeithner - edited - 17 Mar 2026
avatar laoneo laoneo - close - 17 Mar 2026
avatar laoneo
laoneo - comment - 17 Mar 2026

As stated in my last comment, a new Trait should be created which implements the CategoryServiceInterface with your caching changes. In version 7.0 we can then change the core classes to use that one instead the normal one, when this makes sense. Like that we will have a smooth transition and don't risk any regression as this is a central part of the core API, used by many 3rd party extensions as well. Therefor I'm closing this pr till the changes are done in a backwards compatible way.
Nevertheless, thanks for your contribution and I hope you understand the decision.

avatar laoneo laoneo - change - 17 Mar 2026
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2026-03-17 13:58:55
Closed_By laoneo
Labels Added: PR-6.2-dev
Removed: PR-5.3-dev

Add a Comment

Login with GitHub to post a comment