PR-6.1-dev Pending

User tests: Successful: Unsuccessful:

avatar ZaherMadi
ZaherMadi
16 Oct 2025

// 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 # .

Summary of Changes

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

Testing Instructions

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.

Actual result BEFORE applying this Pull Request

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.

Expected result AFTER applying this Pull Request

No warning about duplicate class declaration.

Normal page rendering.

applyAliasFor skips already existing aliases gracefully.

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 ZaherMadi ZaherMadi - open - 16 Oct 2025
avatar ZaherMadi ZaherMadi - change - 16 Oct 2025
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 16 Oct 2025
Category Libraries
avatar brianteeman
brianteeman - comment - 16 Oct 2025

Can you provide an example extension that triggers this error for testing please

avatar ZaherMadi
ZaherMadi - comment - 16 Oct 2025

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)
:

Capture d’écran 2025-10-16 à 16 18 52

System - Essentials Framework (Author : Zoolanders) (Back) :

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.

avatar richard67
richard67 - comment - 25 Oct 2025
avatar ZaherMadi ZaherMadi - change - 4 Nov 2025
Labels Added: PR-6.1-dev
avatar ZaherMadi
ZaherMadi - comment - 4 Nov 2025

It should be fine now.

avatar Stevec4
Stevec4 - comment - 10 Dec 2025

I have the same issue with Zoo. I tested it and confirm it fixes the issue

avatar richard67
richard67 - comment - 10 Dec 2025

I have the same issue with Zoo. I tested it and confirm it fixes the issue

@Stevec4 If that means that you have successfully tested this pull request, then please go to the PR in the issue tracker here https://issues.joomla.org/tracker/joomla-cms/46300 and use the blue "Test this" button at the top left corner to select your test result and submit so your test is properly counted. Thanks in advance.

avatar ZaherMadi
ZaherMadi - comment - 11 Dec 2025

I’ll take note for next time about the bad code style.

Add a Comment

Login with GitHub to post a comment