Ticket #22704: 22704.6.diff
| File 22704.6.diff, 2.8 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 elseif ( ! $this->test_if_site_is_ok() ) 1305 $try_rollback = true; 1306 1301 1307 // 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'] ) {1308 if ( $try_rollback && $parsed_args['attempt_rollback'] && $current->packages->rollback && ! $parsed_args['do_rollback'] ) { 1303 1309 apply_filters( 'update_feedback', $result ); 1304 1310 apply_filters( 'update_feedback', $this->strings['start_rollback'] ); 1305 1311 … … 1366 1372 return false; 1367 1373 } 1368 1374 1375 function test_if_site_is_ok() { 1376 // Is the Admin ajax handler returning what we expect of it? 1377 $http_result = wp_remote_post( admin_url( 'admin-ajax.php?action=test-upgrade-OK' ), array( 'timeout' => 10 ) ); 1378 $admin_ok = ! is_wp_error( $http_result ) && ( 'OK' === wp_remote_retrieve_body( $http_result ) ); 1379 1380 if ( ! $admin_ok ) 1381 return false; 1382 1383 // Is the front-end returning what we'd expect of it? (Note, this is a filter on template_redirect + wp_footer below) 1384 // This WILL break with caching plugins, a POST should make it past most caching plugins, but I suspect not all of them 1385 $http_result = wp_remote_post( site_url( '?test-upgrade-OK=1' ), array( 'timeout' => 10 ) ); 1386 $front_ok = ! is_wp_error( $http_result ) && ( 'OK' === wp_remote_retrieve_body( $http_result ) ); 1387 1388 if ( ! $front_ok ) 1389 return false; 1390 1391 return true; 1392 } 1393 1369 1394 function check_files() { 1370 1395 global $wp_version; 1371 1396 -
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 528 524 529 /** 525 530 * Schedule core, theme, and plugin update checks. 526 531 * … … 562 567 add_action( 'wp_update_themes', 'wp_update_themes' ); 563 568 add_action( 'upgrader_process_complete', 'wp_update_themes' ); 564 569 570 add_action('init', 'wp_schedule_update_checks'); 571 565 572 // Automatic Updates - Cron callback 566 573 add_action( 'wp_auto_updates_maybe_update', 'wp_auto_updates_maybe_update' ); 567 574 568 add_action('init', 'wp_schedule_update_checks'); 575 // Automatic Updates - Site is OK callbacks 576 if ( isset( $_GET['test-upgrade-OK'] ) ) 577 add_action( 'template_redirect', 'site_is_OK_callback' ); 578 579 add_action( 'wp_ajax_test-upgrade-OK', 'site_is_OK_callback' ); 580 add_action( 'wp_ajax_nopriv_test-upgrade-OK', 'site_is_OK_callback' );