Make WordPress Core

Ticket #20974: 20974.diff

File 20974.diff, 5.0 KB (added by nacin, 13 years ago)

Includes some debug to allow for repeated update testing.

  • wp-admin/includes/class-wp-upgrader.php

     
    10551055                if ( is_wp_error($working_dir) )
    10561056                        return $working_dir;
    10571057
    1058                 // Copy update-core.php from the new version into place.
     1058/*              // Copy update-core.php from the new version into place.
    10591059                if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) {
    10601060                        $wp_filesystem->delete($working_dir, true);
    10611061                        return new WP_Error('copy_failed', $this->strings['copy_failed']);
    10621062                }
    10631063                $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
    1064 
     1064*/
    10651065                require(ABSPATH . 'wp-admin/includes/update-core.php');
    10661066
    10671067                if ( ! function_exists( 'update_core' ) )
  • wp-admin/includes/update-core.php

     
    398398);
    399399
    400400/**
     401 * Stores locale files to be deleted.
     402 *
     403 * @since 3.5.0
     404 * @global array $_old_locale_files
     405 * @var array
     406 * @name $_old_locale_files
     407 */
     408global $_old_locale_files;
     409
     410$_old_locale_files = array(
     411        // 3.4
     412        'sv_SE.php',
     413        'pl_PL.php',
     414        'ar.php',
     415        'id_ID.php',
     416        'nb_NO.php',
     417        'fi.php',
     418        'en_CA.php',
     419        'nn_NO.php',
     420        'eo.php',
     421        'ckb.php',
     422        'pt_BR.php',
     423);
     424
     425/**
    401426 * Stores new files in wp-content to copy
    402427 *
    403428 * The contents of this array indicate any new bundled plugins/themes which
     
    469494 * @return WP_Error|null WP_Error on failure, null on success.
    470495 */
    471496function update_core($from, $to) {
    472         global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb;
     497        global $wp_filesystem, $_old_files, $_old_locale_files, $_new_bundled_files, $wpdb;
    473498
    474499        @set_time_limit( 300 );
    475500
     
    518543        $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE);
    519544
    520545        // Copy new versions of WP files into place.
    521         $result = _copy_dir($from . $distro, $to, array('wp-content') );
     546        $result = true; // @DEBUG _copy_dir($from . $distro, $to, array('wp-content') );
    522547
    523548        // Custom Content Directory needs updating now.
    524549        // Copy Languages
    525         if ( !is_wp_error($result) && $wp_filesystem->is_dir($from . $distro . 'wp-content/languages') ) {
     550        if ( !is_wp_error($result) ) {
    526551                if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir(WP_LANG_DIR) )
    527552                        $lang_dir = WP_LANG_DIR;
    528553                else
    529554                        $lang_dir = WP_CONTENT_DIR . '/languages';
     555       
     556                if ( $wp_filesystem->is_dir($from . $distro . 'wp-content/languages') ) {
     557                        if ( !@is_dir($lang_dir) && 0 === strpos($lang_dir, ABSPATH) ) { // Check the language directory exists first
     558                                $wp_filesystem->mkdir($to . str_replace(ABSPATH, '', $lang_dir), FS_CHMOD_DIR); // If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
     559                                clearstatcache(); // for FTP, Need to clear the stat cache
     560                        }
    530561
    531                 if ( !@is_dir($lang_dir) && 0 === strpos($lang_dir, ABSPATH) ) { // Check the language directory exists first
    532                         $wp_filesystem->mkdir($to . str_replace(ABSPATH, '', $lang_dir), FS_CHMOD_DIR); // If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
    533                         clearstatcache(); // for FTP, Need to clear the stat cache
     562                        if ( @is_dir($lang_dir) ) {
     563                                $wp_lang_dir = $wp_filesystem->find_folder($lang_dir);
     564                                if ( $wp_lang_dir )
     565                                        $result = copy_dir($from . $distro . 'wp-content/languages/', $wp_lang_dir);
     566                        }
     567                } elseif ( @is_dir( $lang_dir ) ) {
     568                        $wp_lang_dir = $wp_filesystem->find_folder( $lang_dir );
    534569                }
    535 
    536                 if ( @is_dir($lang_dir) ) {
    537                         $wp_lang_dir = $wp_filesystem->find_folder($lang_dir);
    538                         if ( $wp_lang_dir )
    539                                 $result = copy_dir($from . $distro . 'wp-content/languages/', $wp_lang_dir);
    540                 }
    541570        }
    542571
    543572        // Copy New bundled plugins & themes
    544573        // This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue.
    545         if ( !is_wp_error($result) && ( ! defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
     574        if ( false ) { // @DEBUG !is_wp_error($result) && ( ! defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
    546575                $old_version = $GLOBALS['wp_version']; // $wp_version in local scope == new version
    547576                foreach ( (array) $_new_bundled_files as $file => $introduced_version ) {
    548577                        // If $introduced version is greater than what the site was previously running
     
    591620                $wp_filesystem->delete($old_file, true);
    592621        }
    593622
     623        if ( ! empty( $wp_lang_dir ) ) {
     624                foreach ( $_old_locale_files as $old_file ) {
     625                        $old_file = $wp_lang_dir . $old_file;
     626                        if ( ! $wp_filesystem->exists( $old_file ) )
     627                                continue;
     628                        $wp_filesystem->delete( $old_file, true );
     629                }
     630        }
     631
    594632        // Upgrade DB with separate request
    595633        apply_filters('update_feedback', __('Upgrading database…'));
    596634        $db_upgrade_url = admin_url('upgrade.php?step=upgrade_db');