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

Autoloader: Load only latest version of autoload files to avoid conflicts. #14582

Merged
merged 6 commits into from
Feb 11, 2020

Conversation

superdav42
Copy link
Contributor

Fixes #14389

Changes proposed in this Pull Request:

  • Register each autoload file declaration and keep track of versions in the same way we do for classes. Only after all plugins have registered their packages and plugins loaded is fired should we attempt to include the files so that only the latest version is loaded.

Is this a new feature or does it add/remove features to an existing part of Jetpack?

No, just a bug fix should cause no BC breaks.

Testing instructions:

  • See issue for plugin to test with.
  • Activate both and obverse no errors
  • Also try other plugins which use jetpack autoloader to ensure they still fuction.
  • Trying as many different composer packages is helpful

Proposed changelog entry for your changes:

  • Fix: Conflicts which can occur when jetpack autoloader includes autoload files in the wrong order.

@superdav42 superdav42 added the [Status] Needs Review To request a review from Crew. Label will be renamed soon. label Feb 5, 2020
@superdav42 superdav42 requested a review from a team as a code owner February 5, 2020 18:45
@github-actions github-actions bot added the [Status] Needs Package Release This PR made changes to a package. Let's update that package now. label Feb 5, 2020
@jetpackbot
Copy link

jetpackbot commented Feb 5, 2020

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: March 3, 2020.
Scheduled code freeze: February 25, 2020

Generated by 🚫 dangerJS against 4bf8ca0

Register each autoload file declaration and keep track of versions
in the same way we do for classes. Only after all plugins
have registered their packages and plugins loaded is fired
should we attempt to include the files so that only the latest
version is loaded.

Fixes #14389
Copy link
Member

@kbrown9 kbrown9 left a comment

Choose a reason for hiding this comment

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

I left some comments; most of them are just nitpicks.

The README for the autoloader package also needs to be updated.

packages/autoloader/tests/php/test_file_loader.php Outdated Show resolved Hide resolved
packages/autoloader/tests/php/test_Autoloader.php Outdated Show resolved Hide resolved
packages/autoloader/src/autoload.php Outdated Show resolved Hide resolved
packages/autoloader/src/autoload.php Outdated Show resolved Hide resolved
packages/autoloader/src/autoload.php Show resolved Hide resolved
packages/autoloader/src/autoload.php Outdated Show resolved Hide resolved
packages/autoloader/src/AutoloadGenerator.php Show resolved Hide resolved
packages/autoloader/src/AutoloadGenerator.php Outdated Show resolved Hide resolved
packages/autoloader/src/AutoloadGenerator.php Outdated Show resolved Hide resolved
packages/autoloader/src/AutoloadGenerator.php Outdated Show resolved Hide resolved
@kbrown9 kbrown9 requested review from enejb and zinigor February 6, 2020 10:09
@kbrown9 kbrown9 added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Feb 6, 2020
@kbrown9
Copy link
Member

kbrown9 commented Feb 11, 2020

This looks good to me!

I manually tested two scenarios:

Reproduced Issue #14389

  1. I installed the two plugins provided in issue Jetpack Autoloader: Conflicts can occur when the autoload files are used #14389.
  2. I reproduced the issue caused by the classes being installed from one version of the dependency and files being installed from another version of the dependency.
  3. I used the updated Autoloader package from this branch in the plugins.
  4. I confirmed that the autoload_files_package.php files were properly generated for each plugin.
  5. I confirmed that no errors were generated by the plugins.

Two Plugins using the Jetpack Connection Package

We have a test plugin, Client Example, that uses the Jetpack Connection package. That package autoloads a file, so I tested this branch on a site with the Client Example and Jetpack plugins activated.

  1. I manually added the new autoloader package to Client Example.
  2. I confirmed that the autoload_files_package.php files were properly generated for both plugins.
  3. I added log statements to the autoloaded file (legacy/load-ixr.php), manually adjusted the file versions in the autoload_files_package.php files, and confirmed that the expected versions of the files were installed.

Copy link
Member

@zinigor zinigor left a comment

Choose a reason for hiding this comment

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

Looks good and works good, thank you!

@zinigor zinigor added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Feb 11, 2020
@kbrown9 kbrown9 merged commit c45b4e6 into master Feb 11, 2020
@kbrown9 kbrown9 deleted the fix/autoloader-files-conflict branch February 11, 2020 20:35
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Feb 11, 2020
@jeherve jeherve removed the [Status] Needs Package Release This PR made changes to a package. Let's update that package now. label Feb 14, 2020
jeherve added a commit that referenced this pull request Feb 25, 2020
jeherve added a commit that referenced this pull request Feb 25, 2020
* 8.3 release: changelog

* Changelog: add #14516

* Changelog: add #14574

* Bring in changes from 8.2.1 and 8.2.2

* Update stable version

* Bring in 8.2.3 changes

* Changelog: add #14714

* Changelog: add #14639

* Changelog: add #14678

* Changelog: add #14673

* Changelog: add #14687

* Changelog: add #14704

* Changelog: add #14702

* Changelog: add #14541

* Changelog: add #14657

* Changelog: add #14622

* Changelog: add #14582

* Changelog: add #14638

* Changelog: add #14633

* Changelog: add #14571

* Changelog: add #14592

* Changelog: add #14539

* Changelog: add #14514

* Changelog: add #14643

* Changelog: add #14494

* Changelog: add #13739

* Changelog: add #14707

* Changelog: add #14736

* Changelog: add #14706

* Changelog: add #14730

* Changelog: add #14685

* Changelog: add #14727

* Changelog: add #14711

* Changelog: add #14742

* Changelog: add #14746

* Changelog: add #14725

* Changelog: add #13999

* Changelog: add #14740

* Changelog: add #14759

* Changelog: add #14703

* Changelog: add #14753

* Changelog: add #14754

* Changelog: add #14645

* Cahngelog: add #14599
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.

Jetpack Autoloader: Conflicts can occur when the autoload files are used
7 participants