WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (4 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/upgrade.php

    r42201 r42343  
    2323require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    2424
    25 delete_site_transient('update_core');
     25delete_site_transient( 'update_core' );
    2626
    27 if ( isset( $_GET['step'] ) )
     27if ( isset( $_GET['step'] ) ) {
    2828    $step = $_GET['step'];
    29 else
     29} else {
    3030    $step = 0;
     31}
    3132
    3233// Do it. No output.
     
    4647$step = (int) $step;
    4748
    48 $php_version    = phpversion();
    49 $mysql_version  = $wpdb->db_version();
    50 $php_compat     = version_compare( $php_version, $required_php_version, '>=' );
    51 if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
     49$php_version   = phpversion();
     50$mysql_version = $wpdb->db_version();
     51$php_compat    = version_compare( $php_version, $required_php_version, '>=' );
     52if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
    5253    $mysql_compat = true;
    53 else
     54} else {
    5455    $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
     56}
    5557
    5658@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
     
    7173<p id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>" tabindex="-1"><?php _e( 'WordPress' ); ?></a></p>
    7274
    73 <?php if ( get_option( 'db_version' ) == $wp_db_version || !is_blog_installed() ) : ?>
     75<?php if ( get_option( 'db_version' ) == $wp_db_version || ! is_blog_installed() ) : ?>
    7476
    7577<h1><?php _e( 'No Update Required' ); ?></h1>
     
    7779<p class="step"><a class="button button-large" href="<?php echo get_option( 'home' ); ?>/"><?php _e( 'Continue' ); ?></a></p>
    7880
    79 <?php elseif ( !$php_compat || !$mysql_compat ) :
    80     if ( !$mysql_compat && !$php_compat )
    81         printf( __('You cannot update because <a href="https://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 );
    82     elseif ( !$php_compat )
    83         printf( __('You cannot update because <a href="https://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 );
    84     elseif ( !$mysql_compat )
    85         printf( __('You cannot update because <a href="https://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 );
     81<?php
     82elseif ( ! $php_compat || ! $mysql_compat ) :
     83    if ( ! $mysql_compat && ! $php_compat ) {
     84        printf( __( 'You cannot update because <a href="https://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 );
     85    } elseif ( ! $php_compat ) {
     86        printf( __( 'You cannot update because <a href="https://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 );
     87    } elseif ( ! $mysql_compat ) {
     88        printf( __( 'You cannot update because <a href="https://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 );
     89    }
    8690?>
    87 <?php else :
    88 switch ( $step ) :
    89     case 0:
    90         $goback = wp_get_referer();
    91         if ( $goback ) {
    92             $goback = esc_url_raw( $goback );
    93             $goback = urlencode( $goback );
    94         }
    95 ?>
    96 <h1><?php _e( 'Database Update Required' ); ?></h1>
     91<?php
     92else :
     93    switch ( $step ) :
     94        case 0:
     95            $goback = wp_get_referer();
     96            if ( $goback ) {
     97                $goback = esc_url_raw( $goback );
     98                $goback = urlencode( $goback );
     99            }
     100    ?>
     101    <h1><?php _e( 'Database Update Required' ); ?></h1>
    97102<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>
    98103<p><?php _e( 'The database update process may take a little while, so please be patient.' ); ?></p>
    99104<p class="step"><a class="button button-large button-primary" href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e( 'Update WordPress Database' ); ?></a></p>
    100105<?php
    101         break;
    102     case 1:
    103         wp_upgrade();
     106            break;
     107        case 1:
     108            wp_upgrade();
    104109
    105             $backto = !empty($_GET['backto']) ? wp_unslash( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/';
     110            $backto = ! empty( $_GET['backto'] ) ? wp_unslash( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/';
    106111            $backto = esc_url( $backto );
    107             $backto = wp_validate_redirect($backto, __get_option( 'home' ) . '/');
    108 ?>
    109 <h1><?php _e( 'Update Complete' ); ?></h1>
     112            $backto = wp_validate_redirect( $backto, __get_option( 'home' ) . '/' );
     113    ?>
     114    <h1><?php _e( 'Update Complete' ); ?></h1>
    110115    <p><?php _e( 'Your WordPress database has been successfully updated!' ); ?></p>
    111116    <p class="step"><a class="button button-large" href="<?php echo $backto; ?>"><?php _e( 'Continue' ); ?></a></p>
     
    120125
    121126<?php
    122         break;
     127            break;
    123128endswitch;
    124129endif;
Note: See TracChangeset for help on using the changeset viewer.