User tests: Successful: Unsuccessful:
// applyAliasFor($class) : Check that the alias does not already exist before creating it. in order to avoid an error such as: Cannot declare class joomla\cms\filesystem\folder, because the name is already in use
Pull Request for Issue # .
This PR updates the applyAliasFor($class) method in libraries/loader.php to check whether an alias already exists before creating it with class_alias().
This prevents errors like: Warning: Cannot declare class joomla\cms\filesystem\folder, because the name is already in use
Go to the Joomla administrator dashboard.
Install or enable an extension that triggers a duplicate alias for a core class (e.g., joomla\cms\filesystem\folder).
Reload the dashboard page.
✅ Expected behavior after applying this patch:
No PHP warning is thrown.
The dashboard loads correctly.
Warning: Cannot declare class joomla\cms\filesystem\folder, because the name is already in use
The page may break or the back-office interface may not render correctly.
No warning about duplicate class declaration.
Normal page rendering.
applyAliasFor skips already existing aliases gracefully.
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
| Status | New | ⇒ | Pending |
| Category | ⇒ | Libraries |
For an example that causes the duplicate class alias error:
In my case, the issue occurs when using the ZOO / YOOtheme stack, for example:
System - ZOO YOOtheme Pro (Front)
System - ZOO YOOtheme Pro - Essentials (Front)
:
System - Essentials Framework (Author : Zoolanders) (Back) :
I just realized the issue actually happens on version 6.0.0.
I should probably set the target to 6.0 instead of 6.1.
I can update it if needed.
@ZaherMadi Please fix the code style issues. See https://github.com/joomla/joomla-cms/actions/runs/18563625656/job/52919231600?pr=46300 .
| Labels |
Added:
PR-6.1-dev
|
||
It should be fine now.
Can you provide an example extension that triggers this error for testing please