Make WordPress Core

Ticket #51686: 51686.2.diff

File 51686.2.diff, 1.4 KB (added by kirasong, 5 years ago)

Move one invalidation call after chmod, per @SergeyBiryukov's recommendation, and add comments.

  • src/wp-admin/includes/update-core.php

    diff --git src/wp-admin/includes/update-core.php src/wp-admin/includes/update-core.php
    index 6d9d243ddd2..9d0452dbcbc 100644
    function update_core( $from, $to ) { 
    946946        }
    947947
    948948        $wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE );
     949
     950        /*
     951         * `wp_opcache_invalidate()` only exists in WordPress 5.5 or later,
     952         * so don't run it when upgrading from older versions.
     953         */
     954        if ( function_exists( 'wp_opcache_invalidate' ) ) {
     955                wp_opcache_invalidate( $versions_file );
     956        }
     957
    949958        require WP_CONTENT_DIR . '/upgrade/version-current.php';
    950959        $wp_filesystem->delete( $versions_file );
    951960
    function update_core( $from, $to ) { 
    11171126                        $result = new WP_Error( 'copy_failed_for_version_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-includes/version.php' );
    11181127                }
    11191128                $wp_filesystem->chmod( $to . 'wp-includes/version.php', FS_CHMOD_FILE );
     1129
     1130                /*
     1131                 * `wp_opcache_invalidate()` only exists in WordPress 5.5 or later,
     1132                 * so don't run it when upgrading from older versions.
     1133                 */
     1134                if ( function_exists( 'wp_opcache_invalidate' ) ) {
     1135                        wp_opcache_invalidate( $to . 'wp-includes/version.php' );
     1136                }
    11201137        }
    11211138
    11221139        // Check to make sure everything copied correctly, ignoring the contents of wp-content.