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

Avoid "Cannot declare class ElasticPressLabs" error #43

Merged
merged 2 commits into from
Feb 27, 2023
Merged

Avoid "Cannot declare class ElasticPressLabs" error #43

merged 2 commits into from
Feb 27, 2023

Conversation

ecaron
Copy link
Contributor

@ecaron ecaron commented Oct 21, 2022

Description of the Change

Depending on if ElasticPressLabs or ElasticPress plugin is loaded first, there's a situation where core.php's maybe_load_features function and ElasticPress' Features.php's setup_features both run - which causes the class to attempt two loads.

Moving the register_subfeatures to require_once prevents this conflict, while keeping the other feature loading functionality in place.

How to test the Change

Either change the order the plugins have been installed into your repo, or manually alter with WordPress' activated_plugin action. The behavior can be experienced if you toggle the load order between ElasticPress and ElasticPressLabs.

Changelog Entry

Fixed - Ensure feature classes are only loaded once.

Credits

Props @ecaron

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.

Depending on if ElasticPressLabs or ElasticPress plugin is loaded first, there's a situation where `core.php`'s `maybe_load_features` function and ElasticPress' `Features.php`'s `setup_features` both run  - which causes the class to attempt two loads.

Moving the `register_subfeatures` to `require_once` prevents this conflict, while keeping the other feature loading functionality in place.
@ecaron
Copy link
Contributor Author

ecaron commented Nov 6, 2022

@felipeelia Bump on this (trying to prep the PR for 10up/ElasticPress#3029)

@felipeelia felipeelia merged commit 4238285 into 10up:develop Feb 27, 2023
@felipeelia felipeelia added this to the 2.1.0 milestone Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants