Make WordPress Core

Ticket #2447: upgrade.diff

File upgrade.diff, 4.6 KB (added by markjaquith, 20 years ago)
  • wp-admin/admin.php

     
    44else
    55    require_once('../wp-config.php');
    66
    7 if ( get_option('db_version') != $wp_db_version )
    8         die (sprintf(__("Your database is out-of-date.  Please <a href='%s'>upgrade</a>."), get_option('siteurl') . '/wp-admin/upgrade.php'));
    9    
     7if ( get_option('db_version') != $wp_db_version ) {
     8        wp_redirect(get_option('siteurl') . '/wp-admin/upgrade.php');
     9        die();
     10}
     11
    1012require_once(ABSPATH . 'wp-admin/admin-functions.php');
    1113require_once(ABSPATH . 'wp-admin/admin-db.php');
    1214require_once(ABSPATH . WPINC . '/registration-functions.php');
  • wp-admin/upgrade-functions.php

     
    88        global $wp_current_db_version, $wp_db_version, $wp_rewrite;
    99        $wp_current_db_version = __get_option('db_version');
    1010
     11        // Return of true indicates that upgrade took place
     12        $return = false;
     13
    1114        // We are up-to-date.  Nothing to do.
    1215        if ( $wp_db_version == $wp_current_db_version )
    13                 return;
     16                return false;
    1417
    1518        // If the version is not set in the DB, try to guess the version.
    1619        if ( empty($wp_current_db_version) ) {
     
    2932                upgrade_101();
    3033                upgrade_110();
    3134                upgrade_130();
     35                $return = true;
    3236        }
    3337
    34         if ( $wp_current_db_version < 3308 )
     38        if ( $wp_current_db_version < 3308 ) {
    3539                upgrade_160();
     40                $return = true;
     41        }
    3642
    37         if ( $wp_current_db_version < 3582 )
     43        if ( $wp_current_db_version < 3582 ) {
    3844                upgrade_210();
     45                $return = true;
     46        }
    3947
    4048        $wp_rewrite->flush_rules();
    4149
    4250        update_option('db_version', $wp_db_version);
     51
     52        return $return;
    4353}
    4454
    4555function upgrade_100() {
     
    731741
    732742        $alterations = dbDelta($wp_queries);
    733743        echo "<ol>\n";
    734         foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
     744        foreach ( (array) $alterations as $alteration) echo "<li>$alteration</li>\n";
    735745        echo "</ol>\n";
     746        if ( $alterations )
     747                return true;
     748        return false;
    736749}
    737750
    738751function make_db_current_silent() {
    739752        global $wp_queries;
    740753
    741754        $alterations = dbDelta($wp_queries);
     755        if ( $alterations )
     756                return true;
     757        return false;
    742758}
    743759
    744760function make_site_theme_from_oldschool($theme_name, $template) {
  • wp-admin/upgrade.php

     
    55timer_start();
    66require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
    77
    8 $step = $_GET['step'];
    9 if (!$step) $step = 0;
    108header( 'Content-Type: text/html; charset=utf-8' );
    119?>
    1210<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    6361</head>
    6462<body>
    6563<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
     64<h2><?php _e('Upgrading WordPress'); ?></h2>
     65<p><?php _e('WordPress is now attempting to upgrade your data'); ?></p>
     66<ol>
    6667<?php
    67 switch($step) {
    68 
    69         case 0:
    7068        $goback = wp_specialchars($_SERVER['HTTP_REFERER'], 1);
    71 ?>
    72 <p><?php _e('This file upgrades you from any previous version of WordPress to the latest. It may take a while though, so be patient.'); ?></p>
    73         <h2 class="step"><a href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress &raquo;'); ?></a></h2>
     69        wp_cache_flush();
     70?>
     71<li><?php _e('Attempting to sync database...'); ?><ul><li>
     72<?php if ( make_db_current_silent() )
     73                        _e('Database sync complete!');
     74                else
     75                        _e('No database sync was necessary.');
     76?></li></ul></li>
     77<li><?php _e('Attempting data upgrade...'); ?><ul><li>
     78<?php if ( upgrade_all() )
     79                        _e('Upgrade complete!');
     80                else
     81                        _e('No upgrade was necessary.');
     82?></li></ul></li>
     83</ol>
    7484<?php
    75         break;
    76 
    77         case 1:
    7885        wp_cache_flush();
    79         make_db_current_silent();
    80         upgrade_all();
    81         wp_cache_flush();
    8286
    8387        if ( empty( $_GET['backto'] ) )
    8488                $backto = __get_option('home');
    8589        else
    8690                $backto = wp_specialchars( $_GET['backto'] , 1 );
    8791?>
    88 <h2><?php _e('Step 1'); ?></h2>
    89         <p><?php printf(__("There's actually only one step. So if you see this, you're done. <a href='%s'>Have fun</a>!"),  $backto); ?></p>
     92<h2><?php _e('Upgrade Complete'); ?></h2>
     93        <p><?php printf(__("The upgrade has completed, so you can <a href='%s'>go back to what you were doing</a>!"),  $backto); ?></p>
     94<script><!--
     95setTimeout('window.location=\'<?php echo $backto; ?>\';', 10000);
     96//-->
     97</script>
    9098
    9199<!--
    92100<pre>
     
    96104</pre>
    97105-->
    98106
    99 <?php
    100         break;
    101 }
    102 ?>
    103107</body>
    104 </html>
     108</html>
     109 No newline at end of file