Ticket #27772: 27772.2.diff
File 27772.2.diff, 4.3 KB (added by , 11 years ago) |
---|
-
src/wp-includes/update.php
141 141 else 142 142 $offer[ $offer_key ] = esc_html( $value ); 143 143 } 144 144 $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale', 145 145 'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email' ), '' ) ); 146 146 } 147 147 148 148 $updates = new stdClass(); 149 149 $updates->updates = $offers; 150 150 $updates->last_checked = time(); 151 151 $updates->version_checked = $wp_version; 152 152 153 153 if ( isset( $body['translations'] ) ) 154 154 $updates->translations = $body['translations']; 155 155 156 set_site_transient( 'update_core', $updates); 156 set_site_transient( 'update_core', $updates ); 157 158 // Testing only, causes an update cron task to be run every 90seconds 159 $body['ttl'] = 90; 160 161 if ( !empty( $body['ttl'] ) ) { 162 $ttl = (int) $body['ttl']; 163 if ( $ttl && ( time() + $ttl < wp_next_scheduled( 'wp_version_check' ) ) ) { 164 // Queue an event to re-run the update check in $ttl seconds 165 wp_schedule_single_event( time() + $ttl, 'wp_version_check' ); 166 } 167 } 168 169 // Trigger a Background Updates check if running non-interactively, and we weren't called from the update handler 170 if ( defined( 'DOING_CRON' ) && DOING_CRON && ! doing_action( 'wp_maybe_auto_update' ) ) { 171 do_action( 'wp_maybe_auto_update' ); 172 } 157 173 } 158 174 159 175 /** 160 176 * Check plugin versions against the latest versions hosted on WordPress.org. 161 177 * 162 178 * The WordPress version, PHP version, and Locale is sent along with a list of 163 179 * all plugins installed. Checks against the WordPress server at 164 180 * api.wordpress.org. Will only check if WordPress isn't installing. 165 181 * 166 182 * @since 2.3.0 167 183 * @uses $wp_version Used to notify the WordPress version. 168 184 * 169 185 * @param array $extra_stats Extra statistics to report to the WordPress.org API. 170 186 * @return mixed Returns null if update is unsupported. Returns false if check is too soon. 171 187 */ … … 191 207 $new_option->last_checked = time(); 192 208 193 209 // Check for update on a different schedule, depending on the page. 194 210 switch ( current_filter() ) { 195 211 case 'upgrader_process_complete' : 196 212 $timeout = 0; 197 213 break; 198 214 case 'load-update-core.php' : 199 215 $timeout = MINUTE_IN_SECONDS; 200 216 break; 201 217 case 'load-plugins.php' : 202 218 case 'load-update.php' : 203 219 $timeout = HOUR_IN_SECONDS; 204 220 break; 205 221 default : 206 $timeout = 12 * HOUR_IN_SECONDS; 222 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { 223 $timeout = 0; 224 } else { 225 $timeout = 12 * HOUR_IN_SECONDS; 226 } 207 227 } 208 228 209 229 $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); 210 230 211 231 if ( $time_not_changed && ! $extra_stats ) { 212 232 $plugin_changed = false; 213 233 foreach ( $plugins as $file => $p ) { 214 234 $new_option->checked[ $file ] = $p['Version']; 215 235 216 236 if ( !isset( $current->checked[ $file ] ) || strval($current->checked[ $file ]) !== strval($p['Version']) ) 217 237 $plugin_changed = true; 218 238 } 219 239 220 240 if ( isset ( $current->response ) && is_array( $current->response ) ) { 221 241 foreach ( $current->response as $plugin_file => $update_details ) { … … 337 357 } 338 358 339 359 // Check for update on a different schedule, depending on the page. 340 360 switch ( current_filter() ) { 341 361 case 'upgrader_process_complete' : 342 362 $timeout = 0; 343 363 break; 344 364 case 'load-update-core.php' : 345 365 $timeout = MINUTE_IN_SECONDS; 346 366 break; 347 367 case 'load-themes.php' : 348 368 case 'load-update.php' : 349 369 $timeout = HOUR_IN_SECONDS; 350 370 break; 351 371 default : 352 $timeout = 12 * HOUR_IN_SECONDS; 372 if ( defined( 'DOING_CRON' ) && DOING_CRON ) { 373 $timeout = 0; 374 } else { 375 $timeout = 12 * HOUR_IN_SECONDS; 376 } 353 377 } 354 378 355 379 $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time() - $last_update->last_checked ); 356 380 357 381 if ( $time_not_changed && ! $extra_stats ) { 358 382 $theme_changed = false; 359 383 foreach ( $checked as $slug => $v ) { 360 384 if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) ) 361 385 $theme_changed = true; 362 386 } 363 387 364 388 if ( isset ( $last_update->response ) && is_array( $last_update->response ) ) { 365 389 foreach ( $last_update->response as $slug => $update_details ) { 366 390 if ( ! isset($checked[ $slug ]) ) { 367 391 $theme_changed = true;