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.
Fixes #51686, #51281.
See #36455.
Built from https://develop.svn.wordpress.org/trunk@50475


git-svn-id: http://core.svn.wordpress.org/trunk@50086 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Mike Schroder 2021-03-02 17:13:03 +00:00
parent a2a326b7cc
commit 34b0dc8023
2 changed files with 18 additions and 1 deletions

View 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.

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8-alpha-50474';
$wp_version = '5.8-alpha-50475';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.