Skip to content

Conversation

@ZaherMadi
Copy link

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

// 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
@brianteeman
Copy link
Contributor

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

@ZaherMadi
Copy link
Author

ZaherMadi commented Oct 16, 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.

@richard67
Copy link
Member

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants