Changes from branches/3.1/wp-admin/includes/update-core.php at r18043 to trunk/wp-admin/includes/update-core.php at r18268
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/update-core.php
r18043 r18268 226 226 'wp-includes/js/tinymce/blank.htm', 227 227 'wp-includes/js/tinymce/plugins/safari', 228 'wp-includes/js/tinymce/plugins/media',229 228 'wp-admin/edit-link-categories.php', 230 229 'wp-admin/edit-post-rows.php', … … 244 243 'wp-admin/images/visit-site-button-grad.gif', 245 244 'wp-includes/classes.php', 245 // 3.2 246 'wp-includes/default-embeds.php', 247 'wp-includes/class-json.php', 248 'wp-includes/js/tinymce/plugins/wordpress/img/more.gif', 249 'wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif', 250 'wp-includes/js/tinymce/plugins/wordpress/img/help.gif', 251 'wp-includes/js/tinymce/themes/advanced/img/fm.gif', 252 'wp-includes/js/tinymce/themes/advanced/img/sflogo.png', 253 'wp-admin/js/list-table.js', 254 'wp-admin/js/list-table.dev.js', 255 'wp-admin/images/logo-login.gif' 256 ); 257 258 /** 259 * Stores new files in wp-content to copy 260 * 261 * The contents of this array indicate any new bundled plugins/themes which 262 * should be installed with the WordPress Upgrade. These items will not be 263 * re-installed in future upgrades, this behaviour is controlled by the 264 * introduced version present here being older than the current installed version. 265 * 266 * The content of this array should follow the following format: 267 * Filename (relative to wp-content) => Introduced version 268 * Directories should be noted by suffixing it with a trailing slash (/) 269 * 270 * @since 3.2.0 271 * @global array $_new_bundled_files 272 * @var array 273 * @name $_new_bundled_files 274 */ 275 global $_new_bundled_files; 276 277 $_new_bundled_files = array( 278 'plugins/akismet/' => '2.0', 279 'themes/twentyten/' => '3.0', 280 'themes/twentyeleven/' => '3.2' 246 281 ); 247 282 … … 255 290 * The files in the {@link $_old_files} list will be removed and the new files 256 291 * copied from the zip file after the database is upgraded. 292 * 293 * The files in the {@link $_new_bundled_files} list will be added to the installation 294 * if the version is greater than or equal to the old version being upgraded. 257 295 * 258 296 * The steps for the upgrader for after the new release is downloaded and … … 262 300 * 3. Copy new WordPress directory over old WordPress files. 263 301 * 4. Upgrade WordPress to new version. 302 * 4.1. Copy all files/folders other than wp-content 303 * 4.2. Copy any language files to WP_LANG_DIR (which may differ from WP_CONTENT_DIR 304 * 4.3. Copy any new bundled themes/plugins to their respective locations 264 305 * 5. Delete new WordPress directory path. 265 306 * 6. Delete .maintenance file. … … 287 328 */ 288 329 function update_core($from, $to) { 289 global $wp_filesystem, $_old_files, $ wpdb;330 global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb; 290 331 291 332 @set_time_limit( 300 ); … … 293 334 $php_version = phpversion(); 294 335 $mysql_version = $wpdb->db_version(); 295 $required_php_version = ' 4.3';296 $required_mysql_version = ' 4.1.2';297 $wp_version = '3. 1.3';336 $required_php_version = '5.2.4'; 337 $required_mysql_version = '5.0'; 338 $wp_version = '3.2'; 298 339 $php_compat = version_compare( $php_version, $required_php_version, '>=' ); 299 340 $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' ); … … 312 353 apply_filters('update_feedback', __('Verifying the unpacked files…')); 313 354 $distro = ''; 314 $roots = array( '/wordpress ', '/wordpress-mu' );355 $roots = array( '/wordpress/', '/wordpress-mu/' ); 315 356 foreach( $roots as $root ) { 316 if ( $wp_filesystem->exists($from . $root . '/wp-settings.php') && $wp_filesystem->exists($from . $root . '/wp-admin/admin.php') && 317 $wp_filesystem->exists($from . $root . '/wp-includes/functions.php') ) { 357 if ( $wp_filesystem->exists($from . $root . 'readme.html') && $wp_filesystem->exists($from . $root . 'wp-includes/version.php') ) { 318 358 $distro = $root; 319 359 break; … … 334 374 335 375 // Copy new versions of WP files into place. 336 $result = copy_dir($from . $distro, $to); 376 $result = _copy_dir($from . $distro, $to, array('wp-content') ); 377 378 // Custom Content Directory needs updating now. 379 // Copy Languages 380 if ( !is_wp_error($result) && $wp_filesystem->is_dir($from . $distro . 'wp-content/languages') ) { 381 if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir(WP_LANG_DIR) ) 382 $lang_dir = WP_LANG_DIR; 383 else 384 $lang_dir = WP_CONTENT_DIR . '/languages'; 385 386 if ( !@is_dir($lang_dir) && 0 === strpos($lang_dir, ABSPATH) ) { // Check the language directory exists first 387 $wp_filesystem->mkdir($to . str_replace($lang_dir, ABSPATH, ''), FS_CHMOD_DIR); // If it's within the ABSPATH we can handle it here, otherwise they're out of luck. 388 clearstatcache(); // for FTP, Need to clear the stat cache 389 } 390 391 if ( @is_dir($lang_dir) ) { 392 $wp_lang_dir = $wp_filesystem->find_folder($lang_dir); 393 if ( $wp_lang_dir ) 394 $result = copy_dir($from . $distro . 'wp-content/languages/', $wp_lang_dir); 395 } 396 } 397 398 // Copy New bundled plugins & themes 399 // This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue. 400 if ( !is_wp_error($result) && ( ! defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) { 401 $old_version = $GLOBALS['wp_version']; // $wp_version in local scope == new version 402 foreach ( (array) $_new_bundled_files as $file => $introduced_version ) { 403 // If $introduced version is greater than what the site was previously running 404 if ( version_compare($introduced_version, $old_version, '>') ) { 405 $directory = ('/' == $file[ strlen($file)-1 ]); 406 list($type, $filename) = explode('/', $file, 2); 407 408 if ( 'plugins' == $type ) 409 $dest = $wp_filesystem->wp_plugins_dir(); 410 elseif ( 'themes' == $type ) 411 $dest = trailingslashit($wp_filesystem->wp_themes_dir()); // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2 412 else 413 continue; 414 415 if ( ! $directory ) { 416 if ( $wp_filesystem->exists($dest . $filename) ) 417 continue; 418 419 if ( ! $wp_filesystem->copy($from . $distro . 'wp-content/' . $file, $dest . $filename, FS_CHMOD_FILE) ) 420 $result = new WP_Error('copy_failed', __('Could not copy file.'), $dest . $filename); 421 } else { 422 if ( $wp_filesystem->is_dir($dest . $filename) ) 423 continue; 424 425 $wp_filesystem->mkdir($dest . $filename, FS_CHMOD_DIR); 426 $_result = copy_dir( $from . $distro . 'wp-content/' . $file, $dest . $filename); 427 if ( is_wp_error($_result) ) //If a error occurs partway through this final step, keep the error flowing through, but keep process going. 428 $result = $_result; 429 } 430 } 431 } //end foreach 432 } 433 434 // Handle $result error from the above blocks 337 435 if ( is_wp_error($result) ) { 338 436 $wp_filesystem->delete($maintenance_file); … … 367 465 } 368 466 467 /** 468 * Copies a directory from one location to another via the WordPress Filesystem Abstraction. 469 * Assumes that WP_Filesystem() has already been called and setup. 470 * 471 * This is a temporary function for the 3.1 -> 3.2 upgrade only and will be removed in 3.3 472 * 473 * @ignore 474 * @since 3.2.0 475 * @see copy_dir() 476 * 477 * @param string $from source directory 478 * @param string $to destination directory 479 * @param array $skip_list a list of files/folders to skip copying 480 * @return mixed WP_Error on failure, True on success. 481 */ 482 function _copy_dir($from, $to, $skip_list = array() ) { 483 global $wp_filesystem; 484 485 $dirlist = $wp_filesystem->dirlist($from); 486 487 $from = trailingslashit($from); 488 $to = trailingslashit($to); 489 490 $skip_regex = ''; 491 foreach ( (array)$skip_list as $key => $skip_file ) 492 $skip_regex .= preg_quote($skip_file, '!') . '|'; 493 494 if ( !empty($skip_regex) ) 495 $skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i'; 496 497 foreach ( (array) $dirlist as $filename => $fileinfo ) { 498 if ( !empty($skip_regex) ) 499 if ( preg_match($skip_regex, $from . $filename) ) 500 continue; 501 502 if ( 'f' == $fileinfo['type'] ) { 503 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { 504 // If copy failed, chmod file to 0644 and try again. 505 $wp_filesystem->chmod($to . $filename, 0644); 506 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) 507 return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename); 508 } 509 } elseif ( 'd' == $fileinfo['type'] ) { 510 if ( !$wp_filesystem->is_dir($to . $filename) ) { 511 if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) 512 return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename); 513 } 514 $result = _copy_dir($from . $filename, $to . $filename, $skip_list); 515 if ( is_wp_error($result) ) 516 return $result; 517 } 518 } 519 return true; 520 } 521 369 522 ?>
Note: See TracChangeset
for help on using the changeset viewer.