mirror of
git://develop.git.wordpress.org/
synced 2025-04-05 12:42:35 +02:00
Upgrade/Install: Restore or clean up the temporary plugin or theme backup on shutdown.
This allows these actions to run ''after'' the main process, without affecting the update. Actions running on `shutdown` are immune to PHP timeouts, so in case the failure was due to a PHP timeout, we'll still be able to properly restore the previous version. Follow-up to [51815], [51898], [51899]. Props aristath, peterwilsoncc. See #54166. git-svn-id: https://develop.svn.wordpress.org/trunk@51902 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6367c01844
commit
1227fc5119
@ -843,7 +843,18 @@ class WP_Upgrader {
|
||||
$this->skin->set_result( $result );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
if ( ! empty( $options['hook_extra']['temp_backup'] ) ) {
|
||||
$this->restore_temp_backup( $options['hook_extra']['temp_backup'] );
|
||||
/*
|
||||
* Restore the backup on shutdown.
|
||||
* Actions running on `shutdown` are immune to PHP timeouts,
|
||||
* so in case the failure was due to a PHP timeout,
|
||||
* we'll still be able to properly restore the previous version.
|
||||
*/
|
||||
add_action(
|
||||
'shutdown',
|
||||
function() use ( $options ) {
|
||||
$this->restore_temp_backup( $options['hook_extra']['temp_backup'] );
|
||||
}
|
||||
);
|
||||
}
|
||||
$this->skin->error( $result );
|
||||
|
||||
@ -859,7 +870,13 @@ class WP_Upgrader {
|
||||
|
||||
// Clean up the backup kept in the temp-backup directory.
|
||||
if ( ! empty( $options['hook_extra']['temp_backup'] ) ) {
|
||||
$this->delete_temp_backup( $options['hook_extra']['temp_backup'] );
|
||||
// Delete the backup on `shutdown` to avoid a PHP timeout.
|
||||
add_action(
|
||||
'shutdown',
|
||||
function() use ( $options ) {
|
||||
$this->delete_temp_backup( $options['hook_extra']['temp_backup'] );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $options['is_multi'] ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user