Changeset 58128 for trunk/src/wp-admin/includes/class-wp-upgrader.php
- Timestamp:
- 05/10/2024 11:46:51 AM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-upgrader.php
r58105 r58128 902 902 903 903 if ( is_wp_error( $result ) ) { 904 // An automatic plugin update will have already performed its rollback. 904 905 if ( ! empty( $options['hook_extra']['temp_backup'] ) ) { 905 906 $this->temp_restores[] = $options['hook_extra']['temp_backup']; … … 910 911 * so in case the failure was due to a PHP timeout, 911 912 * it will still be able to properly restore the previous version. 913 * 914 * Zero arguments are accepted as a string can sometimes be passed 915 * internally during actions, causing an error because 916 * `WP_Upgrader::restore_temp_backup()` expects an array. 912 917 */ 913 add_action( 'shutdown', array( $this, 'restore_temp_backup' ) );918 add_action( 'shutdown', array( $this, 'restore_temp_backup' ), 10, 0 ); 914 919 } 915 920 $this->skin->error( $result ); … … 984 989 public function maintenance_mode( $enable = false ) { 985 990 global $wp_filesystem; 991 992 if ( ! $wp_filesystem ) { 993 require_once ABSPATH . 'wp-admin/includes/file.php'; 994 WP_Filesystem(); 995 } 996 986 997 $file = $wp_filesystem->abspath() . '.maintenance'; 987 998 if ( $enable ) { 988 $this->skin->feedback( 'maintenance_start' ); 999 if ( ! wp_doing_cron() ) { 1000 $this->skin->feedback( 'maintenance_start' ); 1001 } 989 1002 // Create maintenance file to signal that we are upgrading. 990 1003 $maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; … … 992 1005 $wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE ); 993 1006 } elseif ( ! $enable && $wp_filesystem->exists( $file ) ) { 994 $this->skin->feedback( 'maintenance_end' ); 1007 if ( ! wp_doing_cron() ) { 1008 $this->skin->feedback( 'maintenance_end' ); 1009 } 995 1010 $wp_filesystem->delete( $file ); 996 1011 } … … 1134 1149 * 1135 1150 * @since 6.3.0 1151 * @since 6.6.0 Added the `$temp_backups` parameter. 1136 1152 * 1137 1153 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. 1138 1154 * 1155 * @param array[] $temp_backups { 1156 * Optional. An array of temporary backups. 1157 * 1158 * @type array ...$0 { 1159 * Information about the backup. 1160 * 1161 * @type string $dir The temporary backup location in the upgrade-temp-backup directory. 1162 * @type string $slug The item's slug. 1163 * @type string $src The directory where the original is stored. For example, `WP_PLUGIN_DIR`. 1164 * } 1165 * } 1139 1166 * @return bool|WP_Error True on success, false on early exit, otherwise WP_Error. 1140 1167 */ 1141 public function restore_temp_backup( ) {1168 public function restore_temp_backup( array $temp_backups = array() ) { 1142 1169 global $wp_filesystem; 1143 1170 1144 1171 $errors = new WP_Error(); 1145 1172 1146 foreach ( $this->temp_restores as $args ) { 1173 if ( empty( $temp_backups ) ) { 1174 $temp_backups = $this->temp_restores; 1175 } 1176 1177 foreach ( $temp_backups as $args ) { 1147 1178 if ( empty( $args['slug'] ) || empty( $args['src'] ) || empty( $args['dir'] ) ) { 1148 1179 return false; … … 1187 1218 * 1188 1219 * @since 6.3.0 1220 * @since 6.6.0 Added the `$temp_backups` parameter. 1189 1221 * 1190 1222 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. 1191 1223 * 1224 * @param array[] $temp_backups { 1225 * Optional. An array of temporary backups. 1226 * 1227 * @type array ...$0 { 1228 * Information about the backup. 1229 * 1230 * @type string $dir The temporary backup location in the upgrade-temp-backup directory. 1231 * @type string $slug The item's slug. 1232 * @type string $src The directory where the original is stored. For example, `WP_PLUGIN_DIR`. 1233 * } 1234 * } 1192 1235 * @return bool|WP_Error True on success, false on early exit, otherwise WP_Error. 1193 1236 */ 1194 public function delete_temp_backup( ) {1237 public function delete_temp_backup( array $temp_backups = array() ) { 1195 1238 global $wp_filesystem; 1196 1239 1197 1240 $errors = new WP_Error(); 1198 1241 1199 foreach ( $this->temp_backups as $args ) { 1242 if ( empty( $temp_backups ) ) { 1243 $temp_backups = $this->temp_backups; 1244 } 1245 1246 foreach ( $temp_backups as $args ) { 1200 1247 if ( empty( $args['slug'] ) || empty( $args['dir'] ) ) { 1201 1248 return false;
Note: See TracChangeset
for help on using the changeset viewer.