diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php index be4650a37c..1aeaffee65 100644 --- a/wp-admin/includes/update-core.php +++ b/wp-admin/includes/update-core.php @@ -614,11 +614,34 @@ function update_core($from, $to) { @set_time_limit( 300 ); + // Sanity check the unzipped distribution + apply_filters( 'update_feedback', __('Verifying the unpacked files…') ); + $distro = ''; + $roots = array( '/wordpress/', '/wordpress-mu/' ); + foreach ( $roots as $root ) { + if ( $wp_filesystem->exists( $from . $root . 'readme.html' ) && $wp_filesystem->exists( $from . $root . 'wp-includes/version.php' ) ) { + $distro = $root; + break; + } + } + if ( ! $distro ) { + $wp_filesystem->delete( $from, true ); + return new WP_Error( 'insane_distro', __('The update could not be unpacked') ); + } + + // Import $wp_version, $required_php_version, and $required_mysql_version from the new version + $versions_file = $wp_filesystem->wp_content_dir() . 'upgrade/version-current.php'; + if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) { + $wp_filesystem->delete( $from, true ); + return new WP_Error( 'copy_failed', __('Could not copy file.') ); + } + + $wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE ); + require_once( WP_CONTENT_DIR . '/upgrade/version-current.php' ); + $wp_filesystem->delete( $versions_file ); + $php_version = phpversion(); $mysql_version = $wpdb->db_version(); - $required_php_version = '5.2.4'; - $required_mysql_version = '5.0'; - $wp_version = '3.4'; $old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from $development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // a dash in the version indicates a Development release $php_compat = version_compare( $php_version, $required_php_version, '>=' ); @@ -637,21 +660,6 @@ function update_core($from, $to) { elseif ( !$mysql_compat ) 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 ) ); - // Sanity check the unzipped distribution - apply_filters('update_feedback', __('Verifying the unpacked files…')); - $distro = ''; - $roots = array( '/wordpress/', '/wordpress-mu/' ); - foreach( $roots as $root ) { - if ( $wp_filesystem->exists($from . $root . 'readme.html') && $wp_filesystem->exists($from . $root . 'wp-includes/version.php') ) { - $distro = $root; - break; - } - } - if ( !$distro ) { - $wp_filesystem->delete($from, true); - return new WP_Error('insane_distro', __('The update could not be unpacked') ); - } - apply_filters('update_feedback', __('Installing the latest version…')); // Create maintenance file to signal that we are upgrading