From 41f4aae738f766fddb4f58567998f0363f98e217 Mon Sep 17 00:00:00 2001 From: Mike Schroder Date: Tue, 2 Mar 2021 18:21:03 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/branches/5.7@50477 git-svn-id: http://core.svn.wordpress.org/branches/5.7@50088 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/update-core.php | 24 ++++++++++++++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php index bbf233eb70..9d0452dbcb 100644 --- a/wp-admin/includes/update-core.php +++ b/wp-admin/includes/update-core.php @@ -937,7 +937,7 @@ function update_core( $from, $to ) { * Import $wp_version, $required_php_version, and $required_mysql_version from the new version. * DO NOT globalise any variables imported from `version-current.php` in this function. * - * BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8 + * BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8. */ $versions_file = trailingslashit( $wp_filesystem->wp_content_dir() ) . 'upgrade/version-current.php'; if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) { @@ -946,6 +946,15 @@ function update_core( $from, $to ) { } $wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE ); + + /* + * `wp_opcache_invalidate()` only exists in WordPress 5.5 or later, + * so don't run it when upgrading from older versions. + */ + if ( function_exists( 'wp_opcache_invalidate' ) ) { + wp_opcache_invalidate( $versions_file ); + } + require WP_CONTENT_DIR . '/upgrade/version-current.php'; $wp_filesystem->delete( $versions_file ); @@ -1117,6 +1126,14 @@ function update_core( $from, $to ) { $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' ); } $wp_filesystem->chmod( $to . 'wp-includes/version.php', FS_CHMOD_FILE ); + + /* + * `wp_opcache_invalidate()` only exists in WordPress 5.5 or later, + * so don't run it when upgrading from older versions. + */ + if ( function_exists( 'wp_opcache_invalidate' ) ) { + wp_opcache_invalidate( $to . 'wp-includes/version.php' ); + } } // Check to make sure everything copied correctly, ignoring the contents of wp-content. @@ -1373,7 +1390,10 @@ function _copy_dir( $from, $to, $skip_list = array() ) { } } - // `wp_opcache_invalidate()` only exists in WordPress 5.5, so don't run it when upgrading to 5.5. + /* + * `wp_opcache_invalidate()` only exists in WordPress 5.5 or later, + * so don't run it when upgrading from older versions. + */ if ( function_exists( 'wp_opcache_invalidate' ) ) { wp_opcache_invalidate( $to . $filename ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 958629f63d..21b63547a5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-RC1-50472'; +$wp_version = '5.7-RC1-50477'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.