Make WordPress Core

Changeset 22227


Ignore:
Timestamp:
10/14/2012 03:47:36 AM (14 years ago)
Author:
dd32
Message:

Replace the hard coded version and PHP/MySQL requirements in update-core.php by pulling in the new version.php file during installation. Fixes #22015 #11639. See #21789

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/update-core.php

    r22226 r22227  
    615615        @set_time_limit( 300 );
    616616
     617        // Sanity check the unzipped distribution
     618        apply_filters( 'update_feedback', __('Verifying the unpacked files…') );
     619        $distro = '';
     620        $roots = array( '/wordpress/', '/wordpress-mu/' );
     621        foreach ( $roots as $root ) {
     622                if ( $wp_filesystem->exists( $from . $root . 'readme.html' ) && $wp_filesystem->exists( $from . $root . 'wp-includes/version.php' ) ) {
     623                        $distro = $root;
     624                        break;
     625                }
     626        }
     627        if ( ! $distro ) {
     628                $wp_filesystem->delete( $from, true );
     629                return new WP_Error( 'insane_distro', __('The update could not be unpacked') );
     630        }
     631
     632        // Import $wp_version, $required_php_version, and $required_mysql_version from the new version
     633        $versions_file = $wp_filesystem->wp_content_dir() . 'upgrade/version-current.php';
     634        if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) {
     635                 $wp_filesystem->delete( $from, true );
     636                 return new WP_Error( 'copy_failed', __('Could not copy file.') );
     637        }
     638
     639        $wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE );
     640        require_once( WP_CONTENT_DIR . '/upgrade/version-current.php' );
     641        $wp_filesystem->delete( $versions_file );
     642
    617643        $php_version    = phpversion();
    618644        $mysql_version  = $wpdb->db_version();
    619         $required_php_version = '5.2.4';
    620         $required_mysql_version = '5.0';
    621         $wp_version = '3.4';
    622645        $old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from
    623646        $development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' )  ); // a dash in the version indicates a Development release
    … …  
    637660        elseif ( !$mysql_compat )
    638661                return new WP_Error( 'mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version ) );
    639 
    640         // Sanity check the unzipped distribution
    641         apply_filters('update_feedback', __('Verifying the unpacked files…'));
    642         $distro = '';
    643         $roots = array( '/wordpress/', '/wordpress-mu/' );
    644         foreach( $roots as $root ) {
    645                 if ( $wp_filesystem->exists($from . $root . 'readme.html') && $wp_filesystem->exists($from . $root . 'wp-includes/version.php') ) {
    646                         $distro = $root;
    647                         break;
    648                 }
    649         }
    650         if ( !$distro ) {
    651                 $wp_filesystem->delete($from, true);
    652                 return new WP_Error('insane_distro', __('The update could not be unpacked') );
    653         }
    654662
    655663        apply_filters('update_feedback', __('Installing the latest version…'));
Note: See TracChangeset for help on using the changeset viewer.