-
Notifications
You must be signed in to change notification settings - Fork 808
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
Backup: Add namespace versioning to Helper_Script_Manager and other classes #34739
Backup: Add namespace versioning to Helper_Script_Manager and other classes #34739
Conversation
…lasses When two or more plugins are installed that contain a class with the same name (e.g. the main Jetpack plugin and the Jetpack VaultPress Backup plugin both ship `Automattic\Jetpack\Backup\Helper_Script_Manager` class), the Jetpack autoloader [tries to find and load the newest version of the class with that name](#34297 (comment)), and under certain circumstances it might even decide to load an older version of the class. Specifically, we had issues with the Jetpack VaultPress Backup plugin loading an older version of the `Helper_Script_Manager` class using the newer code, in which case an `abspath` property in `Helper_Script_Manager::install_helper_script()` (#34297) wasn't always returned. * p1703028095475669-slack-CS8UYNPEE To avoid that behavior, and always load the *exact same* version of the class that has been shipped with the plugin, we're adding simple namespace-based versioning to `Helper_Script_Manager`, backup plugin, and other related code. All of the classes that make up the package/plugin got moved to either the `Automattic\Jetpack\Backup\V0001` or the `Automattic\Jetpack\Transport_Helper\V0001` namespace. Code that uses said classes refers to them using the versioned namespace (e.g. `Automattic\Jetpack\Backup\V0001\Helper_Script_Manager::install_helper_script()`, so that once the plugin gets installed, it always loads and uses a specific version of its dependencies (and not an older/newer one, which it might be incompatible with). Older versions of the Jetpack plugins don't use these namespaces (e.g. they refer to the `Helper_Script_Manager` class as `Automattic\Jetpack\Backup\Helper_Script_Manager`), so if the plugin with versioned namespaces gets installed together with an older plugin without those, both should work fine. If we ever need to change the plugin, the process is somewhat cumbersome yet straightforward: 1. Do the changes that you need; 2. Search for `V0001`, replace it with `V0002` everywhere. in order to make sure that older versions of the plugin load and use the `V0001` version of the relevant code, and the newer versions use `V0002`. Relevant discussions: * peaFOp-2ar-p2 * #34297 (comment)
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Backup plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Protect plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. Migration plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick opengrok search didn't turn up anything outside of the monorepo referring to the namespaces being changed, so 🤞 hopefully it won't break Simple.
I didn't review much beyond that and the few notes inline.
projects/packages/backup-helper-script-manager/src/class-helper-script-manager-impl.php
Outdated
Show resolved
Hide resolved
...ackages/backup-helper-script-manager/changelog/backup-helper-script-manager-class-versioning
Outdated
Show resolved
Hide resolved
projects/packages/backup/changelog/backup-helper-script-manager-class-versioning
Outdated
Show resolved
Hide resolved
projects/packages/transport-helper/changelog/backup-helper-script-manager-class-versioning
Outdated
Show resolved
Hide resolved
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version Automattic/jetpack#34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f3cb0d8145c2091840343a17b0d080ee1c. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/7823601613
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version #34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version #34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version
…efore (#35508) * Write helper script to ABSPATH, just like we did before Writing to "wp-content/" has caused some issues, as some hosts don't allow PHP code from "wp-content/" to be accessed directly. * Bump class namespace version #34739 * changelog * Make the test expect the right order of install locations * Fix up project versions * Add proxy `Package_Version` classes with different namespaces * Revert "Add proxy `Package_Version` classes with different namespaces" This reverts commit abd558f. * Don't use namespace versioning in Package_Version, add <...>\V0001\Package_Version proxy * Use correct path to Package_Version in the test * Fix package name in a test * Move test to Automattic\Jetpack\Backup namespace * Move Package_Version's compatibility class to separate file * Add (possibly) missing import * Apply the same behavior to Automattic\Jetpack\Transport_Helper\Package_Version too * Fix up project/package versions again * Fix transport-helper's actions.php to point to the right Package_Version
Add class versioning using PHP namespaces, to make sure that the plugin always loads the expected version of a class.
Proposed changes:
When two or more plugins are installed that contain a class with the same name (e.g. the main Jetpack plugin and the Jetpack VaultPress Backup plugin both ship
Automattic\Jetpack\Backup\Helper_Script_Manager
class), the Jetpack autoloader #34297 (comment), and under certain circumstances it might even decide to load an older version of the class.Specifically, we had issues with the Jetpack VaultPress Backup plugin loading an older version of the
Helper_Script_Manager
class using the newer code, in which case anabspath
property inHelper_Script_Manager::install_helper_script()
(#34297) wasn't always returned.To avoid that behavior, and always load the exact same version of the class that has been shipped with the plugin, we're adding simple namespace-based versioning to
Helper_Script_Manager
, backup plugin, and other related code.All of the classes that make up the package/plugin got moved to either the
Automattic\Jetpack\Backup\V0001
or theAutomattic\Jetpack\Transport_Helper\V0001
namespace. Code that uses said classes refer to them using the versioned namespace (e.g.Automattic\Jetpack\Backup\V0001\Helper_Script_Manager::install_helper_script()
, so that once the plugin gets installed, it always loads and uses a specific version of its dependencies (and not an older/newer one, which it might be incompatible with).Older versions of the Jetpack plugins don't use these namespaces (e.g. they refer to the
Helper_Script_Manager
class asAutomattic\Jetpack\Backup\Helper_Script_Manager
), so if the plugin with versioned namespaces gets installed together with an older plugin without those, both should work fine.If we ever need to change the plugin, the process is somewhat cumbersome yet straightforward:
V0001
, replace it withV0002
everywhere.to make sure that older versions of the plugin load and use the
V0001
version of the relevant code, and the newer versions useV0002
.Relevant discussions:
Other information:
Jetpack product discussion
peaFOp-2ar-p2
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
Just like with #34297, run a Jetpack VaultPress Backup backup without credentials set up, so that the tool is then forced to upload the helper script via Jetpack API and thus trigger this code.
Make sure that the
abspath
property gets always returned in theinstall_helper_script()
results.Also, test with multiple versions/forms of various Jetpack plugins installed, e.g. the newer Jetpack VaultPress Backup plugin (with this patch), and the older main Jetpack plugin (without this patch); make sure that you still always get the
abspath
back.