PR-5.4-dev Pending

User tests: Successful: Unsuccessful:

avatar Hackwar
Hackwar
17 Jun 2025

Summary of Changes

The method JLoader::register() was deprecated 7 years ago in #21781. 7 years later, we are still using this in core, even if in most cases it is just to keep legacy extensions running. While ideally everything should be autoloaded, there are several situations where this method is usefull. I don't think we should remove this in 6.0 and I also think that we should keep this indefinitely for now. That is why I'm reverting the deprecation here in this PR.

Testing Instructions

Codereview and decision by the CMS maintenance team.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar Hackwar Hackwar - open - 17 Jun 2025
avatar Hackwar Hackwar - change - 17 Jun 2025
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 17 Jun 2025
Category Libraries
avatar Bodge-IT Bodge-IT - change - 17 Jun 2025
Title
Undeprecate JLoder::register()
Undeprecate JLoader::register()
avatar Bodge-IT Bodge-IT - edited - 17 Jun 2025
avatar muhme muhme - change - 27 Jun 2025
Labels Added: PR-5.4-dev
avatar laoneo
laoneo - comment - 27 Jun 2025

Why do you want to remove the deprecation?

avatar Hackwar
Hackwar - comment - 27 Jun 2025

Because we are using it still in core and don't have a solution to not use it anymore. Yes, namespaces and auto-loading are the future, but there are situations where people need to override that and for those cases we still need this.

avatar richard67
richard67 - comment - 28 Jun 2025

Places where we use JLoader::register in the core:

F:\Users\Richard\Documents\GitHub\joomla-cms>findstr /s /c:"JLoader::register(" *.php
administrator\components\com_actionlogs\src\Helper\ActionlogsHelper.php:            \JLoader::register($cName, $file);
administrator\components\com_categories\src\Model\CategoriesModel.php:        \JLoader::register($hname, JPATH_SITE . '/components/' . $component . '/helpers/association.php');
administrator\components\com_categories\src\Model\CategoryModel.php:                \JLoader::register($cName, $path);
administrator\components\com_categories\src\Model\CategoryModel.php:        \JLoader::register($hname, JPATH_SITE . '/components/' . $component . '/helpers/association.php');
administrator\components\com_installer\src\Model\DatabaseModel.php:\JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR . '/components/com_admin/script.php');
administrator\components\com_joomlaupdate\src\Model\UpdateModel.php:        \JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR . '/components/com_admin/script.php');
build\phpstan\joomla-bootstrap.php:JLoader::register('JNamespacePsr4Map', JPATH_LIBRARIES . '/namespacemap.php');
components\com_ajax\ajax.php:            JLoader::register($class, $helperFile);
components\com_ajax\ajax.php:            JLoader::register($class, $helperFile);
components\com_tags\src\Helper\RouteHelper.php:            \JLoader::register($explodedRouter[0], $routerFile);
libraries\bootstrap.php:JLoader::register('Crypto', JPATH_LIBRARIES . '/php-encryption/Crypto.php');
libraries\bootstrap.php:JLoader::register('PasswordHash', JPATH_LIBRARIES . '/phpass/PasswordHash.php');
libraries\cms.php:JLoader::register('Crypto', JPATH_LIBRARIES . '/php-encryption/Crypto.php');
libraries\import.legacy.php:JLoader::register('PasswordHash', JPATH_LIBRARIES . '/phpass/PasswordHash.php');
libraries\import.php:JLoader::register('PasswordHash', JPATH_LIBRARIES . '/phpass/PasswordHash.php');
libraries\src\Adapter\Adapter.php:        \JLoader::register($class, $fullpath);
libraries\src\Application\ExtensionNamespaceMapper.php:        \JLoader::register('JNamespacePsr4Map', JPATH_LIBRARIES . '/namespacemap.php');
libraries\src\Cache\CacheController.php:                    \JLoader::register($class, $path);
libraries\src\Cache\CacheStorage.php:            \JLoader::register($class, $path);
libraries\src\Console\RemoveOldFilesCommand.php:        \JLoader::register('JoomlaInstallerScript', JPATH_ADMINISTRATOR . '/components/com_admin/script.php');
libraries\src\Extension\LegacyComponent.php:        \JLoader::register($className, $file);
libraries\src\HTML\HTMLHelper.php:            \JLoader::register($className, $path);
libraries\src\HTML\HTMLHelper.php:                \JLoader::register($className, $path);
libraries\src\Installer\Installer.php:                \JLoader::register($class, $this->_basepath . '/' . $this->_adapterfolder . '/' . $fileName);
libraries\src\Installer\InstallerAdapter.php:            \JLoader::register($classname, $manifestScriptFile);
libraries\src\MVC\Factory\LegacyFactory.php:            \JLoader::register($viewClass, $path);
libraries\src\MVC\View\ListView.php:        \JLoader::register($helperClass, JPATH_COMPONENT . '/helpers/' . $componentName . '.php');
libraries\src\Service\Provider\Config.php:                    \JLoader::register('JConfig', JPATH_CONFIGURATION . '/configuration.php');
modules\mod_languages\src\Helper\LanguagesHelper.php:                \JLoader::register($class, JPATH_SITE . '/components/' . $option . '/helpers/association.php');
plugins\finder\categories\src\Extension\Categories.php:        \JLoader::register($class, JPATH_SITE . '/components/' . $extension_element . '/helpers/route.php');
plugins\system\languagefilter\src\Extension\LanguageFilter.php:                \JLoader::register($cName, Path::clean(JPATH_SITE . '/components/' . $option . '/helpers/association.php'));

F:\Users\Richard\Documents\GitHub\joomla-cms>

I agree with Hannes, I don't see it as realistic that we can change all that in the next few weeks or months so we can remove the method in 6.0 as the deprecation method says.

So either we go the way of this PR here, or we at least change the 6.0 in the deprecation message to at least 7.0.

avatar laoneo
laoneo - comment - 28 Jun 2025

Most of the places where we use this function is either left for backwards compatibility or in deprecated functions. So this deprecation should be left in place and changed to 7.0. But please do not send a wrong signal and support a feature which was ok in PHP 4, but not nowadays.

avatar richard67
richard67 - comment - 11 Jul 2025

Most of the places where we use this function is either left for backwards compatibility or in deprecated functions. So this deprecation should be left in place and changed to 7.0. But please do not send a wrong signal and support a feature which was ok in PHP 4, but not nowadays.

I agree, we should not remove the deprecation but change it to 7.

@Hackwar Could you do that? If done, I could merge by review. Thanks in advance.

Add a Comment

Login with GitHub to post a comment