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

git-svn-id: https://develop.svn.wordpress.org/trunk@22227 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2012-10-14 03:47:36 +00:00
parent 832a3f51a3
commit 0721d15f0c
1 changed files with 26 additions and 18 deletions

View File

@ -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