Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#52381 closed enhancement (fixed)

Add filter for results of `WP_Upgrader::install_package()`

Reported by: afragen's profile afragen Owned by: afragen's profile afragen
Milestone: 5.7 Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords: has-patch early commit
Focuses: Cc:

Description (last modified by afragen)

Adding a filter to the result of install_package() in WP_Upgrader::install_package() allows for the capture and usage of error data resulting from the install_package() function.

The proposed filter additionally allows for a potential plugin/theme rollback in the event of an update failure due to copy_dir(), but more generally a failure during install_package(). A rollback feature for plugin/theme update failures was originally proposed in #51857.

A feature plugin Rollback Update Failure is available for testing utilizing this filter.

Change History (12)

This ticket was mentioned in PR #925 on WordPress/wordpress-develop by afragen.


4 years ago
#1

Adding a filter to the result of copy_dir() in WP_Upgrader::install_package() allows for the capture and usage of error data resulting from the copy_dir() function.

The proposed filter additionally allows for a potential plugin/theme rollback in the event of an update failure due to copy_dir(). A rollback feature for plugin/theme update failures was originally proposed in #51857.

A feature plugin Rollback Update Failure is available for testing utilizing this filter.

Trac ticket: https://core.trac.wordpress.org/ticket/52381

#2 @afragen
4 years ago

  • Milestone changed from Awaiting Review to 5.7

#3 @afragen
4 years ago

  • Description modified (diff)
  • Owner set to afragen
  • Status changed from new to assigned
  • Summary changed from Add filter for results of `copy_dir()` in WP_Upgrader to Add filter for results of `WP_Upgrader::install_package()`

Moved filter to more general upgrader_install_complete after the install_package() process.

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


4 years ago

#5 @hellofromTonya
4 years ago

Update from today's core scrub: this ticket is ready for a code review and then it can be committed for 5.7 Beta 1.

This ticket was mentioned in Slack in #core by afragen. View the logs.


4 years ago

#7 @dd32
4 years ago

Reviewing PR925, it took me quite some time to figure out exactly why it's wanted/required/needed.

Philosophically I feel that upgrader_pre_install and upgrader_post_install should've covered these, however the latter is only run on a successful call to install_package(), and that's written into a lot of existing code, so changing it's behaviour isn't really possible.

Adding a filter, potentially marked as temporary for a feature plugin, makes sense to me, but I'd probably just call it upgrader_install_package_result instead.

#8 @afragen
4 years ago

PR updated for upgrader_install_package_result

Yes, the idea with this filter is to pick up a failure of install_package() not a success as upgrader_post_install picks up.

Last edited 4 years ago by afragen (previous) (diff)

This ticket was mentioned in Slack in #core by afragen. View the logs.


4 years ago

#10 @afragen
4 years ago

  • Keywords commit added

PR updated, ready for commit

This ticket was mentioned in Slack in #core-auto-updates by hellofromtonya. View the logs.


4 years ago

#12 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 50151:

Upgrade/Install: Introduce a filter for the result of WP_Upgrader::install_package().

This allows for the capture and usage of error data from the method, to facilitate a potential plugin/theme rollback in the event of an update failure.

Props afragen, dd32.
Fixes #52381.

Note: See TracTickets for help on using tickets.