Make WordPress Core


Ignore:
Timestamp:
03/02/2021 06:19:42 PM (4 years ago)
Author:
mikeschroder
Message:

Upgrade/Install: Invalidate OPcache for version.php during update.

Invalidate OPcache for wp-content/version.php on update individually, since it's copied separately.

Props stodorovic, krstarica, cenay, desrosj, pbiron, sergeybiryukov, mikeschroder.

Reviewed by mikeschroder, SergeyBiryukov.
Merges [50460] and [50475] to the 5.7 branch.
Fixes #51686, #51281.
See #36455.

Location:
branches/5.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.7

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

    r50149 r50477  
    938938     * DO NOT globalise any variables imported from `version-current.php` in this function.
    939939     *
    940      * BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8
     940     * BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8.
    941941     */
    942942    $versions_file = trailingslashit( $wp_filesystem->wp_content_dir() ) . 'upgrade/version-current.php';
     
    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 );
     
    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
     
    13741391            }
    13751392
    1376             // `wp_opcache_invalidate()` only exists in WordPress 5.5, so don't run it when upgrading to 5.5.
     1393            /*
     1394             * `wp_opcache_invalidate()` only exists in WordPress 5.5 or later,
     1395             * so don't run it when upgrading from older versions.
     1396             */
    13771397            if ( function_exists( 'wp_opcache_invalidate' ) ) {
    13781398                wp_opcache_invalidate( $to . $filename );
Note: See TracChangeset for help on using the changeset viewer.