WordPress.org

Make WordPress Core

Ticket #7965: 7965.diff

File 7965.diff, 5.9 KB (added by nacin, 10 years ago)
  • wp-admin/admin.php

     
    3131
    3232if ( get_option('db_upgraded') ) {
    3333        $wp_rewrite->flush_rules();
    34         update_option( 'db_upgraded',  false );
     34        update_option( 'db_upgraded', false );
    3535
    36         /**
    37          * Runs on the next page load after successful upgrade
    38          *
    39          * @since 2.8
    40          */
    41         do_action('after_db_upgrade');
    42 } elseif ( get_option('db_version') != $wp_db_version ) {
    43         if ( !is_multisite() ) {
    44                 wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI']))));
     36        // Runs on the next page load after successful upgrade
     37        do_action( 'after_db_upgrade' );
     38
     39} elseif ( get_option( 'db_version' ) != $wp_db_version ) {
     40        if ( ! is_multisite() ) {
     41                define( 'WP_INSTALLING', true );
     42                require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     43                delete_site_transient( 'update_core' );
     44                wp_upgrade();
     45                wp_redirect( $_SERVER['REQUEST_URI'] );
    4546                exit;
    4647        } elseif ( apply_filters( 'do_mu_upgrade', true ) ) {
    47                 /**
    48                  * On really small MU installs run the upgrader every time,
    49                  * else run it less often to reduce load.
    50                  *
    51                  * @since 2.8.4b
    52                  */
     48                // On really small MU installs run the upgrader every time,
     49                // else run it less often to reduce load.
    5350                $c = get_blog_count();
    54                 if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) {
     51                if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int) ( $c / 50 ) ) == 1 ) ) {
    5552                        require_once( ABSPATH . WPINC . '/http.php' );
    56                         $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) );
    57                         do_action( 'after_mu_upgrade', $response );
    58                         unset($response);
     53                        wp_upgrade();
     54                        do_action( 'after_mu_upgrade', '' );
    5955                }
    60                 unset($c);
     56                unset( $c );
    6157        }
    6258}
    6359
  • wp-admin/upgrade.php

     
    1717/** Load WordPress Bootstrap */
    1818require( '../wp-load.php' );
    1919
    20 timer_start();
    2120require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     21delete_site_transient( 'update_core' );
    2222
    23 delete_site_transient('update_core');
    24 
    25 if ( isset( $_GET['step'] ) )
    26         $step = $_GET['step'];
    27 else
    28         $step = 0;
    29 
    30 // Do it.  No output.
    31 if ( 'upgrade_db' === $step ) {
    32         wp_upgrade();
     23wp_upgrade();
     24if ( 'upgrade_db' === $_GET['step'] )
    3325        die( '0' );
    34 }
    3526
    36 $step = (int) $step;
    37 
    38 $php_version    = phpversion();
    39 $mysql_version  = $wpdb->db_version();
    40 $php_compat     = version_compare( $php_version, $required_php_version, '>=' );
    41 $mysql_compat   = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
    42 
    43 @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
    44 ?>
    45 <!DOCTYPE html>
    46 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    47 <head>
    48         <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
    49         <title><?php _e( 'WordPress &rsaquo; Update' ); ?></title>
    50         <?php
    51         wp_admin_css( 'install', true );
    52         wp_admin_css( 'ie', true );
    53         ?>
    54 </head>
    55 <body>
    56 <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
    57 
    58 <?php if ( get_option( 'db_version' ) == $wp_db_version || !is_blog_installed() ) : ?>
    59 
    60 <h2><?php _e( 'No Update Required' ); ?></h2>
    61 <p><?php _e( 'Your WordPress database is already up-to-date!' ); ?></p>
    62 <p class="step"><a class="button" href="<?php echo get_option( 'home' ); ?>/"><?php _e( 'Continue' ); ?></a></p>
    63 
    64 <?php elseif ( !$php_compat || !$mysql_compat ) :
    65         if ( !$mysql_compat && !$php_compat )
    66                 printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version );
    67         elseif ( !$php_compat )
    68                 printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version );
    69         elseif ( !$mysql_compat )
    70                 printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version );
    71 ?>
    72 <?php else :
    73 switch ( $step ) :
    74         case 0:
    75                 $goback = stripslashes( wp_get_referer() );
    76                 $goback = esc_url_raw( $goback );
    77                 $goback = urlencode( $goback );
    78 ?>
    79 <h2><?php _e( 'Database Update Required' ); ?></h2>
    80 <p><?php _e( 'WordPress has been updated! Before we send you on your way, we have to update your database to the newest version.' ); ?></p>
    81 <p><?php _e( 'The update process may take a little while, so please be patient.' ); ?></p>
    82 <p class="step"><a class="button" href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e( 'Update WordPress Database' ); ?></a></p>
    83 <?php
    84                 break;
    85         case 1:
    86                 wp_upgrade();
    87 
    88                         $backto = !empty($_GET['backto']) ? stripslashes( urldecode( $_GET['backto'] ) ) :  __get_option( 'home' ) . '/';
    89                         $backto = esc_url( $backto );
    90                         $backto = wp_validate_redirect($backto, __get_option( 'home' ) . '/');
    91 ?>
    92 <h2><?php _e( 'Update Complete' ); ?></h2>
    93         <p><?php _e( 'Your WordPress database has been successfully updated!' ); ?></p>
    94         <p class="step"><a class="button" href="<?php echo $backto; ?>"><?php _e( 'Continue' ); ?></a></p>
    95 
    96 <!--
    97 <pre>
    98 <?php printf( __( '%s queries' ), $wpdb->num_queries ); ?>
    99 
    100 <?php printf( __( '%s seconds' ), timer_stop( 0 ) ); ?>
    101 </pre>
    102 -->
    103 
    104 <?php
    105                 break;
    106 endswitch;
    107 endif;
    108 ?>
    109 </body>
    110 </html>
     27wp_safe_redirect( wp_get_referer() );
     28exit;
     29 No newline at end of file