Opened 2 years ago
Closed 2 years ago
#56057 closed task (blessed) (fixed)
Add conditional to WP_Upgrader::install_package() for Rollback testing
Reported by: | afragen | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.2 | Priority: | normal |
Severity: | normal | Version: | 6.1 |
Component: | Upgrade/Install | Keywords: | has-patch |
Focuses: | Cc: |
Description (last modified by )
In order to facilitate testing of the Rollback feature using the Rollback Update Failure feature plugin, a conditional testing for the feature plugin is needed to utilize the new move_dir()
function.
@SergeyBiryukov reports precedent for this.
Once committed, PR2225 will be updated to remove it.
Updated: New PR allows for more focused filtering of the function copying the downloaded update into the proper place. Located in WP_Upgrader::install_package()
Change History (43)
This ticket was mentioned in PR #2874 on WordPress/wordpress-develop by afragen.
2 years ago
#1
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
2 years ago
#5
@
2 years ago
- Keywords early added
The patch looks good to me.
Are we sure the below indentation is compliant to WP coding standards?
if ( class_exists( 'Rollback_Update_Failure\WP_Upgrader' )
&& function_exists( '\Rollback_Update_Failure\move_dir' )
) {
#9
@
2 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 53578:
SergeyBiryukov commented on PR #2874:
2 years ago
#10
Thanks for the PR! Merged in https://core.trac.wordpress.org/changeset/53578.
#11
follow-up:
↓ 14
@
2 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
I am not fond of the snowflake code for a feature plugin here. While WordPress has a commitment to backward compatibility it is going to have to stick around for a long time.
Is there a reason the use of do_action( "update-custom_{$action}" );
in src/wp-admin/update.php
wasn't expanded to allow the use of custom updaters within the built-in actions?
#12
@
2 years ago
Temporary conditionals for features have precedent in Core as mentioned in this comment.
This conditional is temporary and only during Rollback's testing. It doesn't fall under the backward compatibility promise as the conditional will never make it into a major release.
We had approval from 3-4 committers on this approach. I appreciate that it's not the ideal, but the ideal is not necessary here. The Make post to Call for Testing is also already published.
#13
@
2 years ago
There is a substantial difference between adding an action and checking for a specific class name within a feature plugin that is under development.
There are also circumstantial difference, the existing hook update-custom_{$action}
could have been expanded for use as a robust and future friendly solution.
#14
in reply to:
↑ 11
@
2 years ago
Replying to peterwilsoncc:
Is there a reason the use of
do_action( "update-custom_{$action}" );
insrc/wp-admin/update.php
wasn't expanded to allow the use of custom updaters within the built-in actions?
Thanks for bringing this up! I had not considered using that hook and would be happy to explore that path.
#15
@
2 years ago
It seems that install_package()
fires much before this hook. We need to prevent the copy_dir()
in install_package()
from firing except for when we want.
Not sure we can utilize this hook.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
2 years ago
#17
@
2 years ago
As per today's bugscrub, the idea is to keep it reopened to see if a filter could be used instead of checking for the plugin class name.
Also, it will stay reopened to make sure the temporary conditional is removed when 6.1 is branched, if the feature can't make it to 6.1.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
2 years ago
This ticket was mentioned in Slack in #core by chaion07. View the logs.
2 years ago
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
2 years ago
#21
@
2 years ago
- Keywords early removed
Removing the early
keyword as per today's bugscrub (and the above comment).
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
2 years ago
This ticket was mentioned in Slack in #core by chaion07. View the logs.
2 years ago
#24
@
2 years ago
- Type changed from feature request to task (blessed)
After confirming with @SergeyBiryukov, moving this to a task so work can continue beyond Beta.
This ticket was mentioned in Slack in #core-upgrade-install by costdev. View the logs.
2 years ago
This ticket was mentioned in Slack in #core-upgrade-install by afragen. View the logs.
2 years ago
This ticket was mentioned in PR #3791 on WordPress/wordpress-develop by @afragen.
2 years ago
#30
Instead of the custom conditional for testing Rollback, add a filter hook that enables the ability to use custom code in place of copy_dir()
in WP_Upgrader::install_package()
. If the filter returns the default, false
, then the default copy_dir()
will be used.
Trac ticket: https://core.trac.wordpress.org/ticket/56057
#31
@
2 years ago
I don't think the filter in the linked PR #3791 is well designed.
Instead of introducing a generic hook (be it filter or action) that could be used in multiple use cases, it's introducing a filter that is pretty tightly limited to the use case of testing the rollback plugin.
However, once the rollback plugin is tested the filter needs to be maintained for the forseable future by WordPress maintainers.
#32
follow-up:
↓ 33
@
2 years ago
This filter can also be used by VirtualBox users to switch back to copy_dir()
if rollback is committed. Thereby maintaining its use case.
#33
in reply to:
↑ 32
@
2 years ago
Replying to afragen:
This filter can also be used by VirtualBox users to switch back to
copy_dir()
if rollback is committed. Thereby maintaining its use case.
To repeat myself, again, it is not the job of VirtualBox users to work around limitations in core. It is quite the reverse.
If the intent of this filter is to be a get-out-of-jail-free card for VB users then I am more reluctant to have it in core.
#34
@
2 years ago
If the intent of this filter is to be a get-out-of-jail-free card for VB users then I am more reluctant to have it in core.
To be fair, the PR explains that this wasn't the intent of this filter:
Instead of the custom conditional for testing Rollback, add a filter hook that enables the ability to use custom code in place of copy_dir() in WP_Upgrader::install_package(). If the filter returns the default, false, then the default copy_dir() will be used.
i.e. To avoid having code in Core that specifies a feature plugin, and instead using established Core extensibility features to enable extenders (including feature plugins) to replace functionality where required.
#35
@
2 years ago
As far as I understand it there are no differences between the use cases for the filter in PR #3791 and function_exists()
in [54643]. Both are intended to facilitate development of the Rollback feature plugin. In that terms both are temporary and should not be present in a WordPress release, only in development (alpha, beta, etc.) versions.
If there are other use cases for such filter that may warrant having it permanently in core, please open another (enhancement) ticket about them.
#37
@
2 years ago
As discussed in the slack thread yesterday (requires login via make.wordpress.org/chat) I think the preferable approach it to use the update-custom_{$action}
and update-core-custom_{$action}
hooks to customize the upgrade process for the rollback plugin.
Changing the action on the form submission on either the plugin or core upgrade screen will bypass Core's existing update code and allow you to replace it wholesale.
This will offer greater flexibility than the filter proposed above/checking for a particular callable.
#38
@
2 years ago
While utilizing the update-core-custom_{$action}
and update-custom_{$action}
hooks can work for some upgrade paths, it will not work for all - WP-CLI for example.
This means that testing the rollback plugin via WP-CLI, for example, will require testers to manually change Core to use move_dir()
instead of copy_dir()
.
As we have to ensure that BC is protected in all upgrade paths, the two hooks above are certainly useful, but not a complete replacement for testing the plugin - especially for non-dev contributors who may have WP-CLI, but are unfamilar/uncomfortable with editing code
Any ideas of how paths such as WP-CLI could be covered are much appreciated.
#39
@
2 years ago
You could make a custom command and extend WPCLI\Plugin_Command
or \WP_CLI\CommandWithUpgrade
if needs be.
#40
@
2 years ago
Per @azaozz comment above, I am removing the new filter from discussion here and will create a new ticket at the appropriate time.
Adding a conditional to
WP_Upgrader::install_package()
for testing of Rollback feature and Rollback feature plugin.Trac ticket: https://core.trac.wordpress.org/ticket/56057