Changeset 55720 for trunk/src/wp-includes/update.php
- Timestamp:
- 05/04/2023 02:34:58 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/update.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/update.php
r55641 r55720 1078 1078 } 1079 1079 1080 /** 1081 * Schedules the removal of all contents in the temporary backup directory. 1082 * 1083 * @since 6.3.0 1084 */ 1085 function wp_delete_all_temp_backups() { 1086 /* 1087 * Check if there is a lock, or if currently performing an Ajax request, 1088 * in which case there is a chance an update is running. 1089 * Reschedule for an hour from now and exit early. 1090 */ 1091 if ( get_option( 'core_updater.lock' ) || get_option( 'auto_updater.lock' ) || wp_doing_ajax() ) { 1092 wp_schedule_single_event( time() + HOUR_IN_SECONDS, 'wp_delete_temp_updater_backups' ); 1093 return; 1094 } 1095 1096 // This action runs on shutdown to make sure there are no plugin updates currently running. 1097 add_action( 'shutdown', '_wp_delete_all_temp_backups' ); 1098 } 1099 1100 /** 1101 * Deletes all contents in the temporary backup directory. 1102 * 1103 * @since 6.3.0 1104 * 1105 * @access private 1106 * 1107 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. 1108 * 1109 * @return void|WP_Error Void on success, or a WP_Error object on failure. 1110 */ 1111 function _wp_delete_all_temp_backups() { 1112 global $wp_filesystem; 1113 1114 if ( ! $wp_filesystem ) { 1115 require_once ABSPATH . '/wp-admin/includes/file.php'; 1116 WP_Filesystem(); 1117 } 1118 1119 if ( ! $wp_filesystem->wp_content_dir() ) { 1120 return new WP_Error( 'fs_no_content_dir', __( 'Unable to locate WordPress content directory (wp-content).' ) ); 1121 } 1122 1123 $temp_backup_dir = $wp_filesystem->wp_content_dir() . 'upgrade-temp-backup/'; 1124 $dirlist = $wp_filesystem->dirlist( $temp_backup_dir ); 1125 $dirlist = $dirlist ? $dirlist : array(); 1126 1127 foreach ( array_keys( $dirlist ) as $dir ) { 1128 if ( '.' === $dir || '..' === $dir ) { 1129 continue; 1130 } 1131 1132 $wp_filesystem->delete( $temp_backup_dir . $dir, true ); 1133 } 1134 } 1135 1080 1136 if ( ( ! is_main_site() && ! is_network_admin() ) || wp_doing_ajax() ) { 1081 1137 return; … … 1102 1158 1103 1159 add_action( 'init', 'wp_schedule_update_checks' ); 1160 1161 add_action( 'wp_delete_temp_updater_backups', 'wp_delete_all_temp_backups' );
Note: See TracChangeset
for help on using the changeset viewer.