Ticket #22704: 22704.whitescreen-rollback.diff
| File 22704.whitescreen-rollback.diff, 3.2 KB (added by , 12 years ago) |
|---|
-
src/wp-admin/includes/class-wp-upgrader.php
1298 1298 1299 1299 $result = update_core( $working_dir, $wp_dir ); 1300 1300 1301 $try_rollback = false; 1302 if ( is_wp_error( $result ) ) { 1303 $try_rollback = true; 1304 } else { 1305 $site_test = $this->test_if_site_is_ok(); 1306 if ( is_wp_error( $site_test ) ) { 1307 $result = $site_test; 1308 $try_rollback = true; 1309 } 1310 } 1311 1301 1312 // In the event of an error, rollback to the previous version 1302 if ( is_wp_error( $result )&& $parsed_args['attempt_rollback'] && $current->packages->rollback && ! $parsed_args['do_rollback'] ) {1313 if ( $try_rollback && $parsed_args['attempt_rollback'] && $current->packages->rollback && ! $parsed_args['do_rollback'] ) { 1303 1314 apply_filters( 'update_feedback', $result ); 1304 1315 apply_filters( 'update_feedback', $this->strings['start_rollback'] ); 1305 1316 … … 1339 1350 } 1340 1351 } 1341 1352 1353 // Don't upgrade if we can't verify that the site is OK 1354 if ( true !== $this->test_if_site_is_ok() ) 1355 return false; 1356 1342 1357 // 1: If we're already on that version, not much point in updating? 1343 1358 if ( $offered_ver == $wp_version ) 1344 1359 return false; … … 1366 1381 return false; 1367 1382 } 1368 1383 1384 function test_if_site_is_ok() { 1385 // Is the Admin ajax handler returning what we expect of it? 1386 $http_result = wp_remote_post( admin_url( 'admin-ajax.php?action=test-upgrade-OK' ), array( 'timeout' => 10 ) ); 1387 $admin_ok = ( 'OK' === wp_remote_retrieve_body( $http_result ) ); 1388 1389 if ( ! $admin_ok ) 1390 return new WP_Error( 'admin_check_failed', __(''), wp_remote_retrieve_body( $http_result ) ); 1391 1392 // Is the front-end returning what we'd expect of it? (Note, This is a filter on template_redirect) 1393 $http_result = wp_remote_post( site_url( '?test-upgrade-OK=1' ), array( 'timeout' => 10 ) ); 1394 $front_ok = ( 'OK' === wp_remote_retrieve_body( $http_result ) ); 1395 1396 if ( ! $front_ok ) 1397 return new WP_Error( 'site_check_failed', __(''), wp_remote_retrieve_body( $http_result ) ); 1398 1399 return true; 1400 } 1401 1369 1402 function check_files() { 1370 1403 global $wp_version; 1371 1404 -
src/wp-includes/update.php
521 521 wp_update_themes(); 522 522 } 523 523 524 function site_is_OK_callback() { 525 die( 'OK' ); 526 } 527 524 528 /** 525 529 * Schedule core, theme, and plugin update checks. 526 530 * … … 562 566 add_action( 'wp_update_themes', 'wp_update_themes' ); 563 567 add_action( 'upgrader_process_complete', 'wp_update_themes' ); 564 568 569 add_action('init', 'wp_schedule_update_checks'); 570 565 571 // Automatic Updates - Cron callback 566 572 add_action( 'wp_auto_updates_maybe_update', 'wp_auto_updates_maybe_update' ); 567 573 568 add_action('init', 'wp_schedule_update_checks'); 574 // Automatic Updates - Site is OK callbacks 575 if ( isset( $_GET['test-upgrade-OK'] ) ) 576 add_action( 'template_redirect', 'site_is_OK_callback' ); 577 578 add_action( 'wp_ajax_test-upgrade-OK', 'site_is_OK_callback' ); 579 add_action( 'wp_ajax_nopriv_test-upgrade-OK', 'site_is_OK_callback' );