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

Fix issue with static methods in class autoloader #172

Merged
merged 1 commit into from
Mar 1, 2023

Conversation

darylldoyle
Copy link
Collaborator

Description of the Change

In #158 we added a way to auto-initialise and load classes in the MU plugin and theme.
Because the classfinder uses static methods, it only works on a single application root.

To get around this, we need to manually set the application root before we look for classes in a namespace, so that it can find the right composer.json file

This has been tested on a client project that's using this version of the scaffold.

How to test the Change

  • Add a class to the MU plugin and another to the theme.
  • Make sure that both are registered.

Changelog Entry

  • Fixed - Issue with class loading conflict.

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

Because the classfinder uses static methods, it only works on a single application root.

To get around this, we need to manually set the application root before we look for classes in a namespace, so that it can find the right composer.json file
@darylldoyle darylldoyle added bug Something isn't working Internal Review labels Feb 15, 2023
@darylldoyle darylldoyle self-assigned this Feb 15, 2023
@darylldoyle
Copy link
Collaborator Author

@joesnellpdx @tlovett1 wondering if one of you could review this since it fixes a bug that could cause engineers some pain in the scaffold.

Copy link
Member

@fabiankaegy fabiankaegy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this on a project and it works great (y)

@fabiankaegy fabiankaegy merged commit 1e1cb14 into trunk Mar 1, 2023
@fabiankaegy fabiankaegy deleted the fix/issue-with-auto-module-conflict branch March 1, 2023 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Internal Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants