web/wp-admin/includes/update-core.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
   393 'wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.dev.js',
   393 'wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.dev.js',
   394 'wp-includes/js/tinymce/plugins/wpgallery/img/gallery.png',
   394 'wp-includes/js/tinymce/plugins/wpgallery/img/gallery.png',
   395 'wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js',
   395 'wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js',
   396 // Don't delete, yet: 'wp-pass.php',
   396 // Don't delete, yet: 'wp-pass.php',
   397 // Don't delete, yet: 'wp-register.php',
   397 // Don't delete, yet: 'wp-register.php',
       
   398 // 3.5
       
   399 'wp-admin/gears-manifest.php',
       
   400 'wp-admin/includes/manifest.php',
       
   401 'wp-admin/images/archive-link.png',
       
   402 'wp-admin/images/blue-grad.png',
       
   403 'wp-admin/images/button-grad-active.png',
       
   404 'wp-admin/images/button-grad.png',
       
   405 'wp-admin/images/ed-bg-vs.gif',
       
   406 'wp-admin/images/ed-bg.gif',
       
   407 'wp-admin/images/fade-butt.png',
       
   408 'wp-admin/images/fav-arrow-rtl.gif',
       
   409 'wp-admin/images/fav-arrow.gif',
       
   410 'wp-admin/images/fav-vs.png',
       
   411 'wp-admin/images/fav.png',
       
   412 'wp-admin/images/gray-grad.png',
       
   413 'wp-admin/images/loading-publish.gif',
       
   414 'wp-admin/images/logo-ghost.png',
       
   415 'wp-admin/images/logo.gif',
       
   416 'wp-admin/images/menu-arrow-frame-rtl.png',
       
   417 'wp-admin/images/menu-arrow-frame.png',
       
   418 'wp-admin/images/menu-arrows.gif',
       
   419 'wp-admin/images/menu-bits-rtl-vs.gif',
       
   420 'wp-admin/images/menu-bits-rtl.gif',
       
   421 'wp-admin/images/menu-bits-vs.gif',
       
   422 'wp-admin/images/menu-bits.gif',
       
   423 'wp-admin/images/menu-dark-rtl-vs.gif',
       
   424 'wp-admin/images/menu-dark-rtl.gif',
       
   425 'wp-admin/images/menu-dark-vs.gif',
       
   426 'wp-admin/images/menu-dark.gif',
       
   427 'wp-admin/images/required.gif',
       
   428 'wp-admin/images/screen-options-toggle-vs.gif',
       
   429 'wp-admin/images/screen-options-toggle.gif',
       
   430 'wp-admin/images/toggle-arrow-rtl.gif',
       
   431 'wp-admin/images/toggle-arrow.gif',
       
   432 'wp-admin/images/upload-classic.png',
       
   433 'wp-admin/images/upload-fresh.png',
       
   434 'wp-admin/images/white-grad-active.png',
       
   435 'wp-admin/images/white-grad.png',
       
   436 'wp-admin/images/widgets-arrow-vs.gif',
       
   437 'wp-admin/images/widgets-arrow.gif',
       
   438 'wp-admin/images/wpspin_dark.gif',
       
   439 'wp-includes/images/upload.png',
       
   440 'wp-includes/js/prototype.js',
       
   441 'wp-includes/js/scriptaculous',
       
   442 'wp-admin/css/wp-admin-rtl.dev.css',
       
   443 'wp-admin/css/wp-admin.dev.css',
       
   444 'wp-admin/css/media-rtl.dev.css',
       
   445 'wp-admin/css/media.dev.css',
       
   446 'wp-admin/css/colors-classic.dev.css',
       
   447 'wp-admin/css/customize-controls-rtl.dev.css',
       
   448 'wp-admin/css/customize-controls.dev.css',
       
   449 'wp-admin/css/ie-rtl.dev.css',
       
   450 'wp-admin/css/ie.dev.css',
       
   451 'wp-admin/css/install.dev.css',
       
   452 'wp-admin/css/colors-fresh.dev.css',
       
   453 'wp-includes/js/customize-base.dev.js',
       
   454 'wp-includes/js/json2.dev.js',
       
   455 'wp-includes/js/comment-reply.dev.js',
       
   456 'wp-includes/js/customize-preview.dev.js',
       
   457 'wp-includes/js/wplink.dev.js',
       
   458 'wp-includes/js/tw-sack.dev.js',
       
   459 'wp-includes/js/wp-list-revisions.dev.js',
       
   460 'wp-includes/js/autosave.dev.js',
       
   461 'wp-includes/js/admin-bar.dev.js',
       
   462 'wp-includes/js/quicktags.dev.js',
       
   463 'wp-includes/js/wp-ajax-response.dev.js',
       
   464 'wp-includes/js/wp-pointer.dev.js',
       
   465 'wp-includes/js/hoverIntent.dev.js',
       
   466 'wp-includes/js/colorpicker.dev.js',
       
   467 'wp-includes/js/wp-lists.dev.js',
       
   468 'wp-includes/js/customize-loader.dev.js',
       
   469 'wp-includes/js/jquery/jquery.table-hotkeys.dev.js',
       
   470 'wp-includes/js/jquery/jquery.color.dev.js',
       
   471 'wp-includes/js/jquery/jquery.color.js',
       
   472 'wp-includes/js/jquery/jquery.hotkeys.dev.js',
       
   473 'wp-includes/js/jquery/jquery.form.dev.js',
       
   474 'wp-includes/js/jquery/suggest.dev.js',
       
   475 'wp-admin/js/xfn.dev.js',
       
   476 'wp-admin/js/set-post-thumbnail.dev.js',
       
   477 'wp-admin/js/comment.dev.js',
       
   478 'wp-admin/js/theme.dev.js',
       
   479 'wp-admin/js/cat.dev.js',
       
   480 'wp-admin/js/password-strength-meter.dev.js',
       
   481 'wp-admin/js/user-profile.dev.js',
       
   482 'wp-admin/js/theme-preview.dev.js',
       
   483 'wp-admin/js/post.dev.js',
       
   484 'wp-admin/js/media-upload.dev.js',
       
   485 'wp-admin/js/word-count.dev.js',
       
   486 'wp-admin/js/plugin-install.dev.js',
       
   487 'wp-admin/js/edit-comments.dev.js',
       
   488 'wp-admin/js/media-gallery.dev.js',
       
   489 'wp-admin/js/custom-fields.dev.js',
       
   490 'wp-admin/js/custom-background.dev.js',
       
   491 'wp-admin/js/common.dev.js',
       
   492 'wp-admin/js/inline-edit-tax.dev.js',
       
   493 'wp-admin/js/gallery.dev.js',
       
   494 'wp-admin/js/utils.dev.js',
       
   495 'wp-admin/js/widgets.dev.js',
       
   496 'wp-admin/js/wp-fullscreen.dev.js',
       
   497 'wp-admin/js/nav-menu.dev.js',
       
   498 'wp-admin/js/dashboard.dev.js',
       
   499 'wp-admin/js/link.dev.js',
       
   500 'wp-admin/js/user-suggest.dev.js',
       
   501 'wp-admin/js/postbox.dev.js',
       
   502 'wp-admin/js/tags.dev.js',
       
   503 'wp-admin/js/image-edit.dev.js',
       
   504 'wp-admin/js/media.dev.js',
       
   505 'wp-admin/js/customize-controls.dev.js',
       
   506 'wp-admin/js/inline-edit-post.dev.js',
       
   507 'wp-admin/js/categories.dev.js',
       
   508 'wp-admin/js/editor.dev.js',
       
   509 'wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.dev.js',
       
   510 'wp-includes/js/tinymce/plugins/wpdialogs/js/popup.dev.js',
       
   511 'wp-includes/js/tinymce/plugins/wpdialogs/js/wpdialog.dev.js',
       
   512 'wp-includes/js/plupload/handlers.dev.js',
       
   513 'wp-includes/js/plupload/wp-plupload.dev.js',
       
   514 'wp-includes/js/swfupload/handlers.dev.js',
       
   515 'wp-includes/js/jcrop/jquery.Jcrop.dev.js',
       
   516 'wp-includes/js/jcrop/jquery.Jcrop.js',
       
   517 'wp-includes/js/jcrop/jquery.Jcrop.css',
       
   518 'wp-includes/js/imgareaselect/jquery.imgareaselect.dev.js',
       
   519 'wp-includes/css/wp-pointer.dev.css',
       
   520 'wp-includes/css/editor.dev.css',
       
   521 'wp-includes/css/jquery-ui-dialog.dev.css',
       
   522 'wp-includes/css/admin-bar-rtl.dev.css',
       
   523 'wp-includes/css/admin-bar.dev.css',
       
   524 'wp-includes/js/jquery/ui/jquery.effects.clip.min.js',
       
   525 'wp-includes/js/jquery/ui/jquery.effects.scale.min.js',
       
   526 'wp-includes/js/jquery/ui/jquery.effects.blind.min.js',
       
   527 'wp-includes/js/jquery/ui/jquery.effects.core.min.js',
       
   528 'wp-includes/js/jquery/ui/jquery.effects.shake.min.js',
       
   529 'wp-includes/js/jquery/ui/jquery.effects.fade.min.js',
       
   530 'wp-includes/js/jquery/ui/jquery.effects.explode.min.js',
       
   531 'wp-includes/js/jquery/ui/jquery.effects.slide.min.js',
       
   532 'wp-includes/js/jquery/ui/jquery.effects.drop.min.js',
       
   533 'wp-includes/js/jquery/ui/jquery.effects.highlight.min.js',
       
   534 'wp-includes/js/jquery/ui/jquery.effects.bounce.min.js',
       
   535 'wp-includes/js/jquery/ui/jquery.effects.pulsate.min.js',
       
   536 'wp-includes/js/jquery/ui/jquery.effects.transfer.min.js',
       
   537 'wp-includes/js/jquery/ui/jquery.effects.fold.min.js',
   398 );
   538 );
   399 
   539 
   400 /**
   540 /**
   401  * Stores new files in wp-content to copy
   541  * Stores new files in wp-content to copy
   402  *
   542  *
   417 global $_new_bundled_files;
   557 global $_new_bundled_files;
   418 
   558 
   419 $_new_bundled_files = array(
   559 $_new_bundled_files = array(
   420 'plugins/akismet/' => '2.0',
   560 'plugins/akismet/' => '2.0',
   421 'themes/twentyten/' => '3.0',
   561 'themes/twentyten/' => '3.0',
   422 'themes/twentyeleven/' => '3.2'
   562 'themes/twentyeleven/' => '3.2',
       
   563 'themes/twentytwelve/' => '3.5',
   423 );
   564 );
   424 
   565 
   425 /**
   566 /**
   426  * Upgrade the core of WordPress.
   567  * Upgrade the core of WordPress.
   427  *
   568  *
   471 function update_core($from, $to) {
   612 function update_core($from, $to) {
   472 	global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb;
   613 	global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb;
   473 
   614 
   474 	@set_time_limit( 300 );
   615 	@set_time_limit( 300 );
   475 
   616 
       
   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 
   476 	$php_version    = phpversion();
   643 	$php_version    = phpversion();
   477 	$mysql_version  = $wpdb->db_version();
   644 	$mysql_version  = $wpdb->db_version();
   478 	$required_php_version = '5.2.4';
   645 	$old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from
   479 	$required_mysql_version = '5.0';
   646 	$development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' )  ); // a dash in the version indicates a Development release
   480 	$wp_version = '3.4.2';
       
   481 	$php_compat     = version_compare( $php_version, $required_php_version, '>=' );
   647 	$php_compat     = version_compare( $php_version, $required_php_version, '>=' );
   482 	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
   648 	if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
   483 		$mysql_compat = true;
   649 		$mysql_compat = true;
   484 	else
   650 	else
   485 		$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
   651 		$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
   491 		return new WP_Error( 'php_mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s 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 ) );
   657 		return new WP_Error( 'php_mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s 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 ) );
   492 	elseif ( !$php_compat )
   658 	elseif ( !$php_compat )
   493 		return new WP_Error( 'php_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version ) );
   659 		return new WP_Error( 'php_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version ) );
   494 	elseif ( !$mysql_compat )
   660 	elseif ( !$mysql_compat )
   495 		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 ) );
   661 		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 ) );
   496 
       
   497 	// Sanity check the unzipped distribution
       
   498 	apply_filters('update_feedback', __('Verifying the unpacked files…'));
       
   499 	$distro = '';
       
   500 	$roots = array( '/wordpress/', '/wordpress-mu/' );
       
   501 	foreach( $roots as $root ) {
       
   502 		if ( $wp_filesystem->exists($from . $root . 'readme.html') && $wp_filesystem->exists($from . $root . 'wp-includes/version.php') ) {
       
   503 			$distro = $root;
       
   504 			break;
       
   505 		}
       
   506 	}
       
   507 	if ( !$distro ) {
       
   508 		$wp_filesystem->delete($from, true);
       
   509 		return new WP_Error('insane_distro', __('The update could not be unpacked') );
       
   510 	}
       
   511 
   662 
   512 	apply_filters('update_feedback', __('Installing the latest version…'));
   663 	apply_filters('update_feedback', __('Installing the latest version…'));
   513 
   664 
   514 	// Create maintenance file to signal that we are upgrading
   665 	// Create maintenance file to signal that we are upgrading
   515 	$maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
   666 	$maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
   540 		}
   691 		}
   541 	}
   692 	}
   542 
   693 
   543 	// Copy New bundled plugins & themes
   694 	// Copy New bundled plugins & themes
   544 	// This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue.
   695 	// This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue.
       
   696 	// $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated
   545 	if ( !is_wp_error($result) && ( ! defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
   697 	if ( !is_wp_error($result) && ( ! defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
   546 		$old_version = $GLOBALS['wp_version']; // $wp_version in local scope == new version
       
   547 		foreach ( (array) $_new_bundled_files as $file => $introduced_version ) {
   698 		foreach ( (array) $_new_bundled_files as $file => $introduced_version ) {
   548 			// If $introduced version is greater than what the site was previously running
   699 			// If a $development_build or if $introduced version is greater than what the site was previously running
   549 			if ( version_compare($introduced_version, $old_version, '>') ) {
   700 			if ( $development_build || version_compare( $introduced_version, $old_wp_version, '>' ) ) {
   550 				$directory = ('/' == $file[ strlen($file)-1 ]);
   701 				$directory = ('/' == $file[ strlen($file)-1 ]);
   551 				list($type, $filename) = explode('/', $file, 2);
   702 				list($type, $filename) = explode('/', $file, 2);
   552 
   703 
   553 				if ( 'plugins' == $type )
   704 				if ( 'plugins' == $type )
   554 					$dest = $wp_filesystem->wp_plugins_dir();
   705 					$dest = $wp_filesystem->wp_plugins_dir();
   556 					$dest = trailingslashit($wp_filesystem->wp_themes_dir()); // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2
   707 					$dest = trailingslashit($wp_filesystem->wp_themes_dir()); // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2
   557 				else
   708 				else
   558 					continue;
   709 					continue;
   559 
   710 
   560 				if ( ! $directory ) {
   711 				if ( ! $directory ) {
   561 					if ( $wp_filesystem->exists($dest . $filename) )
   712 					if ( ! $development_build && $wp_filesystem->exists( $dest . $filename ) )
   562 						continue;
   713 						continue;
   563 
   714 
   564 					if ( ! $wp_filesystem->copy($from . $distro . 'wp-content/' . $file, $dest . $filename, FS_CHMOD_FILE) )
   715 					if ( ! $wp_filesystem->copy($from . $distro . 'wp-content/' . $file, $dest . $filename, FS_CHMOD_FILE) )
   565 						$result = new WP_Error('copy_failed', __('Could not copy file.'), $dest . $filename);
   716 						$result = new WP_Error('copy_failed', __('Could not copy file.'), $dest . $filename);
   566 				} else {
   717 				} else {
   567 					if ( $wp_filesystem->is_dir($dest . $filename) )
   718 					if ( ! $development_build && $wp_filesystem->is_dir( $dest . $filename ) )
   568 						continue;
   719 						continue;
   569 
   720 
   570 					$wp_filesystem->mkdir($dest . $filename, FS_CHMOD_DIR);
   721 					$wp_filesystem->mkdir($dest . $filename, FS_CHMOD_DIR);
   571 					$_result = copy_dir( $from . $distro . 'wp-content/' . $file, $dest . $filename);
   722 					$_result = copy_dir( $from . $distro . 'wp-content/' . $file, $dest . $filename);
   572 					if ( is_wp_error($_result) ) //If a error occurs partway through this final step, keep the error flowing through, but keep process going.
   723 					if ( is_wp_error($_result) ) //If a error occurs partway through this final step, keep the error flowing through, but keep process going.
   678  *
   829  *
   679  */
   830  */
   680 function _redirect_to_about_wordpress( $new_version ) {
   831 function _redirect_to_about_wordpress( $new_version ) {
   681 	global $wp_version, $pagenow, $action;
   832 	global $wp_version, $pagenow, $action;
   682 
   833 
   683 	if ( version_compare( $wp_version, '3.5-alpha', '>=' ) )
   834 	if ( version_compare( $wp_version, '3.4-RC1', '>=' ) )
   684 		return;
   835 		return;
   685 
   836 
   686 	// Ensure we only run this on the update-core.php page. wp_update_core() could be called in other contexts.
   837 	// Ensure we only run this on the update-core.php page. wp_update_core() could be called in other contexts.
   687 	if ( 'update-core.php' != $pagenow )
   838 	if ( 'update-core.php' != $pagenow )
   688 		return;
   839 		return;
   694 	load_default_textdomain();
   845 	load_default_textdomain();
   695 
   846 
   696 	// See do_core_upgrade()
   847 	// See do_core_upgrade()
   697 	show_message( __('WordPress updated successfully') );
   848 	show_message( __('WordPress updated successfully') );
   698 
   849 
   699 	$js_message = __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%s">here</a>.' );
       
   700 	$js_message = str_replace( '"%s"', '"%2$s"', $js_message ); // in lieu of breaking the string.
       
   701 
       
   702 	// self_admin_url() won't exist when upgrading from <= 3.0, so relative URLs are intentional.
   850 	// self_admin_url() won't exist when upgrading from <= 3.0, so relative URLs are intentional.
   703 	show_message( '<span class="hide-if-no-js">' . sprintf( $js_message, $new_version, 'about.php?updated' ) . '</span>' );
   851 	show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%2$s">here</a>.' ), $new_version, 'about.php?updated' ) . '</span>' );
   704 	show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $new_version, 'about.php?updated' ) . '</span>' );
   852 	show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $new_version, 'about.php?updated' ) . '</span>' );
   705 	echo '</div>';
   853 	echo '</div>';
   706 	?>
   854 	?>
   707 <script type="text/javascript">
   855 <script type="text/javascript">
   708 window.location = 'about.php?updated';
   856 window.location = 'about.php?updated';