Feature No Code Attached Yet
avatar janschoenherr
janschoenherr
13 Feb 2025

Problem identified

Joomla\CMS\Categories\Categories::getInstance() has been deprecated with 4.0 and will be removed with 6.0.

The suggested alternative is to use the ComponentInterface.

Factory::getApplication()->bootComponent($component)->getCategory($options, $section);

There is a difference though: getInstance() caches the category service instance. When you query Categories::getInstance($extension, $options)::get() twice for the same category, you'll get the same CategoryNode, without querying the database twice.

Joomla\CMS\Categories\CategoryServiceTrait::getCategory() creates a new categories service on each call and by that you'll not benefit from the nodes cache.

Proposed solution

Is it possible to add an instance cache to the Joomla\CMS\Categories\CategoryServiceTrait?

Open questions

avatar janschoenherr janschoenherr - open - 13 Feb 2025
avatar joomla-cms-bot joomla-cms-bot - change - 13 Feb 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 13 Feb 2025
avatar janschoenherr janschoenherr - change - 13 Feb 2025
The description was changed
avatar janschoenherr janschoenherr - edited - 13 Feb 2025
avatar richard67 richard67 - change - 13 Feb 2025
Labels Added: Feature
avatar richard67 richard67 - labeled - 13 Feb 2025

Add a Comment

Login with GitHub to post a comment