Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation of Joomla\CMS\Categories\Categories::getInstance() #44891

Open
janschoenherr opened this issue Feb 13, 2025 · 0 comments
Open

Deprecation of Joomla\CMS\Categories\Categories::getInstance() #44891

janschoenherr opened this issue Feb 13, 2025 · 0 comments

Comments

@janschoenherr
Copy link
Contributor

janschoenherr commented Feb 13, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants