Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (7 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/update-core.php

    r47099 r47122  
    254254        'wp-includes/js/jquery/interface.js',
    255255        'wp-includes/js/scriptaculous/prototype.js',
    256         // Following file added back in 5.1 see #45645
     256        // Following file added back in 5.1, see #45645.
    257257        //'wp-includes/js/tinymce/wp-tinymce.js',
    258258        // 3.1
    … …  
    537537        'wp-admin/images/screenshots/twitter-embed-2.png',
    538538        'wp-admin/js/utils.js',
    539         // Added back in 5.3 [45448], see #43895
     539        // Added back in 5.3 [45448], see #43895.
    540540        // 'wp-admin/options-privacy.php',
    541541        'wp-app.php',
    … …  
    601601        'wp-admin/css/colors-rtl.css',
    602602        'wp-admin/css/colors-rtl.min.css',
    603         // Following files added back in 4.5 see #36083
     603        // Following files added back in 4.5, see #36083.
    604604        // 'wp-admin/css/media-rtl.min.css',
    605605        // 'wp-admin/css/media.min.css',
    … …  
    616616        'wp-includes/js/plupload/plupload.silverlight.js',
    617617        'wp-includes/js/plupload/plupload.flash.js',
    618         // Added back in 4.9 [41328], see #41755
     618        // Added back in 4.9 [41328], see #41755.
    619619        // 'wp-includes/js/plupload/plupload.js',
    620620        'wp-includes/js/tinymce/plugins/spellchecker',
    … …  
    788788        'wp-includes/js/tinymce/wp-tinymce.js.gz',
    789789        // 5.3
    790         'wp-includes/js/wp-a11y.js', // Moved to: wp-includes/js/dist/a11y.js
     790        'wp-includes/js/wp-a11y.js',     // Moved to: wp-includes/js/dist/a11y.js
    791791        'wp-includes/js/wp-a11y.min.js', // Moved to: wp-includes/js/dist/a11y.min.js
    792792);
    … …  
    939939        $php_version       = phpversion();
    940940        $mysql_version     = $wpdb->db_version();
    941         $old_wp_version    = $GLOBALS['wp_version']; // The version of WordPress we're updating from
    942         $development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // a dash in the version indicates a Development release
     941        $old_wp_version    = $GLOBALS['wp_version']; // The version of WordPress we're updating from.
     942        $development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // A dash in the version indicates a development release.
    943943        $php_compat        = version_compare( $php_version, $required_php_version, '>=' );
    944944        if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
    … …  
    10181018        apply_filters( 'update_feedback', __( 'Preparing to install the latest version…' ) );
    10191019
    1020         // Don't copy wp-content, we'll deal with that below
    1021         // We also copy version.php last so failed updates report their old version
     1020        // Don't copy wp-content, we'll deal with that below.
     1021        // We also copy version.php last so failed updates report their old version.
    10221022        $skip              = array( 'wp-content', 'wp-includes/version.php' );
    10231023        $check_is_writable = array();
    10241024
    1025         // Check to see which files don't really need updating - only available for 3.7 and higher
     1025        // Check to see which files don't really need updating - only available for 3.7 and higher.
    10261026        if ( function_exists( 'get_core_checksums' ) ) {
    1027                 // Find the local version of the working directory
     1027                // Find the local version of the working directory.
    10281028                $working_dir_local = WP_CONTENT_DIR . '/upgrade/' . basename( $from ) . $distro;
    10291029
    10301030                $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
    10311031                if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) ) {
    1032                         $checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2
     1032                        $checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2.
    10331033                }
    10341034                if ( is_array( $checksums ) ) {
    … …  
    10791079        /** This filter is documented in wp-admin/includes/update-core.php */
    10801080        apply_filters( 'update_feedback', __( 'Enabling Maintenance mode…' ) );
    1081         // Create maintenance file to signal that we are upgrading
     1081        // Create maintenance file to signal that we are upgrading.
    10821082        $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
    10831083        $maintenance_file   = $to . '.maintenance';
    … …  
    10931093        }
    10941094
    1095         // Since we know the core files have copied over, we can now copy the version file
     1095        // Since we know the core files have copied over, we can now copy the version file.
    10961096        if ( ! is_wp_error( $result ) ) {
    10971097                if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $to . 'wp-includes/version.php', true /* overwrite */ ) ) {
    … …  
    11021102        }
    11031103
    1104         // Check to make sure everything copied correctly, ignoring the contents of wp-content
     1104        // Check to make sure everything copied correctly, ignoring the contents of wp-content.
    11051105        $skip   = array( 'wp-content' );
    11061106        $failed = array();
    … …  
    11251125        }
    11261126
    1127         // Some files didn't copy properly
     1127        // Some files didn't copy properly.
    11281128        if ( ! empty( $failed ) ) {
    11291129                $total_size = 0;
    … …  
    11471147        }
    11481148
    1149         // Custom Content Directory needs updating now.
    1150         // Copy Languages
     1149        // Custom content directory needs updating now.
     1150        // Copy languages.
    11511151        if ( ! is_wp_error( $result ) && $wp_filesystem->is_dir( $from . $distro . 'wp-content/languages' ) ) {
    11521152                if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir( WP_LANG_DIR ) ) {
    … …  
    11561156                }
    11571157
    1158                 if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) { // Check the language directory exists first
    1159                         $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.
    1160                         clearstatcache(); // for FTP, Need to clear the stat cache
     1158                // Check if the language directory exists first.
     1159                if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) {
     1160                        // If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
     1161                        $wp_filesystem->mkdir( $to . str_replace( ABSPATH, '', $lang_dir ), FS_CHMOD_DIR );
     1162                        clearstatcache(); // For FTP, need to clear the stat cache.
    11611163                }
    11621164
    … …  
    11741176        /** This filter is documented in wp-admin/includes/update-core.php */
    11751177        apply_filters( 'update_feedback', __( 'Disabling Maintenance mode&#8230;' ) );
    1176         // Remove maintenance file, we're done with potential site-breaking changes
     1178        // Remove maintenance file, we're done with potential site-breaking changes.
    11771179        $wp_filesystem->delete( $maintenance_file );
    11781180
    … …  
    11841186        }
    11851187
    1186         // Copy New bundled plugins & themes
    1187         // This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue.
    1188         // $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated
     1188        /*
     1189         * Copy new bundled plugins & themes.
     1190         * This gives us the ability to install new plugins & themes bundled with
     1191         * future versions of WordPress whilst avoiding the re-install upon upgrade issue.
     1192         * $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated.
     1193         */
    11891194        if ( ! is_wp_error( $result ) && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
    11901195                foreach ( (array) $_new_bundled_files as $file => $introduced_version ) {
    1191                         // If a $development_build or if $introduced version is greater than what the site was previously running
     1196                        // If a $development_build or if $introduced version is greater than what the site was previously running.
    11921197                        if ( $development_build || version_compare( $introduced_version, $old_wp_version, '>' ) ) {
    11931198                                $directory             = ( '/' == $file[ strlen( $file ) - 1 ] );
    11941199                                list($type, $filename) = explode( '/', $file, 2 );
    11951200
    1196                                 // Check to see if the bundled items exist before attempting to copy them
     1201                                // Check to see if the bundled items exist before attempting to copy them.
    11971202                                if ( ! $wp_filesystem->exists( $from . $distro . 'wp-content/' . $file ) ) {
    11981203                                        continue;
    … …  
    12021207                                        $dest = $wp_filesystem->wp_plugins_dir();
    12031208                                } elseif ( 'themes' == $type ) {
    1204                                         $dest = trailingslashit( $wp_filesystem->wp_themes_dir() ); // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2
     1209                                        // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2.
     1210                                        $dest = trailingslashit( $wp_filesystem->wp_themes_dir() );
    12051211                                } else {
    12061212                                        continue;
    … …  
    12321238                                }
    12331239                        }
    1234                 } //end foreach
    1235         }
    1236 
    1237         // Handle $result error from the above blocks
     1240                } // End foreach.
     1241        }
     1242
     1243        // Handle $result error from the above blocks.
    12381244        if ( is_wp_error( $result ) ) {
    12391245                $wp_filesystem->delete( $from, true );
    … …  
    12411247        }
    12421248
    1243         // Remove old files
     1249        // Remove old files.
    12441250        foreach ( $_old_files as $old_file ) {
    12451251                $old_file = $to . $old_file;
    … …  
    12541260        }
    12551261
    1256         // Remove any Genericons example.html's from the filesystem
     1262        // Remove any Genericons example.html's from the filesystem.
    12571263        _upgrade_422_remove_genericons();
    12581264
    1259         // Remove the REST API plugin if its version is Beta 4 or lower
     1265        // Remove the REST API plugin if its version is Beta 4 or lower.
    12601266        _upgrade_440_force_deactivate_incompatible_plugins();
    12611267
    1262         // Upgrade DB with separate request
     1268        // Upgrade DB with separate request.
    12631269        /** This filter is documented in wp-admin/includes/update-core.php */
    12641270        apply_filters( 'update_feedback', __( 'Upgrading database&#8230;' ) );
    … …  
    12661272        wp_remote_post( $db_upgrade_url, array( 'timeout' => 60 ) );
    12671273
    1268         // Clear the cache to prevent an update_option() from saving a stale db_version to the cache
     1274        // Clear the cache to prevent an update_option() from saving a stale db_version to the cache.
    12691275        wp_cache_flush();
    1270         // (Not all cache back ends listen to 'flush')
     1276        // Not all cache back ends listen to 'flush'.
    12711277        wp_cache_delete( 'alloptions', 'options' );
    12721278
    1273         // Remove working directory
     1279        // Remove working directory.
    12741280        $wp_filesystem->delete( $from, true );
    12751281
    1276         // Force refresh of update information
     1282        // Force refresh of update information.
    12771283        if ( function_exists( 'delete_site_transient' ) ) {
    12781284                delete_site_transient( 'update_core' );
    … …  
    13971403        load_default_textdomain();
    13981404
    1399         // See do_core_upgrade()
     1405        // See do_core_upgrade().
    14001406        show_message( __( 'WordPress updated successfully' ) );
    14011407
    … …  
    14431449        $affected_files = array();
    14441450
    1445         // Themes
     1451        // Themes.
    14461452        foreach ( $wp_theme_directories as $directory ) {
    14471453                $affected_theme_files = _upgrade_422_find_genericons_files_in_folder( $directory );
    … …  
    14491455        }
    14501456
    1451         // Plugins
     1457        // Plugins.
    14521458        $affected_plugin_files = _upgrade_422_find_genericons_files_in_folder( WP_PLUGIN_DIR );
    14531459        $affected_files        = array_merge( $affected_files, $affected_plugin_files );
    … …  
    14591465                }
    14601466
    1461                 // The path when the file is accessed via WP_Filesystem may differ in the case of FTP
     1467                // The path when the file is accessed via WP_Filesystem may differ in the case of FTP.
    14621468                $remote_file = $gen_dir . basename( $file );
    14631469
Note: See TracChangeset for help on using the changeset viewer.