From 39edb7abe90dc7afa6bf58b394ffe0be3d9d5904 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 2 Feb 2021 17:29:27 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@50151 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-upgrader.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index 3017b4851d..f35dc7babc 100644 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/wp-admin/includes/class-wp-upgrader.php @@ -798,6 +798,16 @@ class WP_Upgrader { ) ); + /** + * Filters the result of WP_Upgrader::install_package(). + * + * @since 5.7.0 + * + * @param array|WP_Error $result Result from WP_Upgrader::install_package(). + * @param array $hook_extra Extra arguments passed to hooked filters. + */ + $result = apply_filters( 'upgrader_install_package_result', $result, $options['hook_extra'] ); + $this->skin->set_result( $result ); if ( is_wp_error( $result ) ) { $this->skin->error( $result );