Changeset 17576
- Timestamp:
- 03/31/2011 01:28:36 PM (14 years ago)
- Location:
- trunk/wp-admin/includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-filesystem-base.php
r14810 r17576 83 83 */ 84 84 function wp_themes_dir() { 85 return $this->wp_content_dir() . '/themes'; 85 return $this->wp_content_dir() . 'themes/'; 86 } 87 /** 88 * Returns the path on the remote filesystem of WP_LANG_DIR 89 * 90 * @since 3.2 91 * @access public 92 * 93 * @return string The location of the remote path. 94 */ 95 function wp_lang_dir() { 96 return $this->find_folder(WP_LANG_DIR); 86 97 } 87 98 -
trunk/wp-admin/includes/file.php
r17555 r17576 717 717 * @param string $from source directory 718 718 * @param string $to destination directory 719 * @param array $skip_list a list of files/folders to skip copying 719 720 * @return mixed WP_Error on failure, True on success. 720 721 */ 721 function copy_dir($from, $to ) {722 function copy_dir($from, $to, $skip_list = array() ) { 722 723 global $wp_filesystem; 723 724 … … 727 728 $to = trailingslashit($to); 728 729 730 $skip_regex = ''; 731 foreach ( (array)$skip_list as $key => $skip_file ) 732 $skip_regex .= preg_quote($skip_file, '!') . '|'; 733 734 if ( !empty($skip_regex) ) 735 $skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i'; 736 729 737 foreach ( (array) $dirlist as $filename => $fileinfo ) { 738 if ( !empty($skip_regex) ) 739 if ( preg_match($skip_regex, $from . $filename) ) 740 continue; 741 730 742 if ( 'f' == $fileinfo['type'] ) { 731 743 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { … … 740 752 return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename); 741 753 } 742 $result = copy_dir($from . $filename, $to . $filename );754 $result = copy_dir($from . $filename, $to . $filename, $skip_list); 743 755 if ( is_wp_error($result) ) 744 756 return $result; -
trunk/wp-admin/includes/update-core.php
r17561 r17576 247 247 248 248 /** 249 * Stores new files in wp-content to copy 250 * 251 * The contents of this array indicate any new bundled plugins/themes which 252 * should be installed with the WordPress Upgrade. These items will not be 253 * re-installed in future upgrades, this behaviour is controlled by the 254 * introduced version present here being older than the current installed version. 255 * 256 * The content of this array should follow the following format: 257 * Filename (relative to wp-content) => Introduced version 258 * Directories should be noted by suffixing it with a trailing slash (/) 259 * 260 * @since 3.2 261 * @global array $_new_bundled_files 262 * @var array 263 * @name $_new_bundled_files 264 */ 265 global $_new_bundled_files; 266 267 $_new_bundled_files = array( 268 'plugins/akismet/' => '2.0', 269 'themes/twentyten/' => '3.2', 270 ); 271 272 /** 249 273 * Upgrade the core of WordPress. 250 274 * … … 255 279 * The files in the {@link $_old_files} list will be removed and the new files 256 280 * copied from the zip file after the database is upgraded. 281 * 282 * The files in the {@link $_new_bundled_files} list will be added to the installation 283 * if the version is greater than or equal to the old version being upgraded. 257 284 * 258 285 * The steps for the upgrader for after the new release is downloaded and … … 262 289 * 3. Copy new WordPress directory over old WordPress files. 263 290 * 4. Upgrade WordPress to new version. 291 * 4.1. Copy all files/folders other than wp-content 292 * 4.2. Copy any language files to WP_LANG_DIR (which may differ from WP_CONTENT_DIR 293 * 4.3. Copy any new bundled themes/plugins to their respective locations 264 294 * 5. Delete new WordPress directory path. 265 295 * 6. Delete .maintenance file. … … 287 317 */ 288 318 function update_core($from, $to) { 289 global $wp_filesystem, $_old_files, $ wpdb;319 global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb; 290 320 291 321 @set_time_limit( 300 ); … … 312 342 apply_filters('update_feedback', __('Verifying the unpacked files…')); 313 343 $distro = ''; 314 $roots = array( '/wordpress ', '/wordpress-mu' );344 $roots = array( '/wordpress/', '/wordpress-mu/' ); 315 345 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') ) {346 if ( $wp_filesystem->exists($from . $root . 'wp-settings.php') && $wp_filesystem->exists($from . $root . 'wp-admin/admin.php') && 347 $wp_filesystem->exists($from . $root . 'wp-includes/functions.php') ) { 318 348 $distro = $root; 319 349 break; … … 334 364 335 365 // Copy new versions of WP files into place. 336 $result = copy_dir($from . $distro, $to); 366 $result = copy_dir($from . $distro, $to, array('wp-content') ); 367 368 // Custom Content Directory needs updating now. 369 // Copy Languages 370 if ( !is_wp_error($result) && $wp_filesystem->is_dir($from . $distro . 'wp-content/languages') ) { 371 if ( !@is_dir(WP_LANG_DIR) && 0 === strpos(WP_LANG_DIR, ABSPATH) ) { // Check the language directory exists first 372 $wp_filesystem->mkdir($to . str_replace(WP_LANG_DIR, ABSPATH, ''), FS_CHMOD_DIR); // If it's within the ABSPATH we can handle it here, otherwise they're out of luck. 373 clearstatcache(); // for FTP, Need to clear the stat cache 374 } 375 376 if ( @is_dir(WP_LANG_DIR) ) { 377 $wp_lang_dir = $wp_filesystem->wp_lang_dir(); 378 $result = copy_dir($from . $distro . 'wp-content/languages/', $wp_lang_dir); 379 } 380 } 381 382 // Copy New bundled plugins & themes 383 // This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue. 384 if ( !is_wp_error($result) && ( ! defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) { 385 $old_version = $GLOBALS['wp_version']; // $wp_version in local scope == new version 386 foreach ( (array) $_new_bundled_files as $file => $introduced_version ) { 387 // If $introduced version is greater than what the site was previously running 388 if ( version_compare($introduced_version, $old_version, '>') ) { 389 $directory = ('/' == $file[ strlen($file)-1 ]); 390 list($type, $filename) = explode('/', $file, 2); 391 if ( 'plugins' == $type ) 392 $dest = $wp_filesystem->wp_plugins_dir(); 393 elseif ( 'themes' == $type ) 394 $dest = $wp_filesystem->wp_themes_dir(); 395 396 if ( ! $directory ) { 397 if ( $wp_filesystem->exists($dest . '/' . $filename) ) 398 continue; 399 400 if ( ! $wp_filesystem->copy($from . $distro . 'wp-content/' . $file, $dest . '/' . $filename, FS_CHMOD_FILE) ) 401 $result = new WP_Error('copy_failed', __('Could not copy file.'), $dest . '/' . $filename); 402 } else { 403 if ( $wp_filesystem->is_dir($dest . '/' . $filename) ) 404 continue; 405 406 $wp_filesystem->mkdir($dest . $filename, FS_CHMOD_DIR); 407 $_result = copy_dir( $from . $distro . 'wp-content/' . $file, $dest . $filename); 408 if ( is_wp_error($_result) ) //If a error occurs partway through this final step, keep the error flowing through, but keep process going. 409 $result = $_result; 410 } 411 } 412 } //end foreach 413 } 414 415 // Handle $result error from the above blocks 337 416 if ( is_wp_error($result) ) { 338 417 $wp_filesystem->delete($maintenance_file);
Note: See TracChangeset
for help on using the changeset viewer.