General: Memoize the return value in `wp_get_wp_version()`.

Cache the unmodified `$wp_version` value as a static. This retains the current behaviour during the upgrade process `$wp_version` referencing the version of WordPress being upgraded from.

Follow up to [58848].

Props Cybr, debarghyabanerjee, mukesh27, costdev, SergeyBiryukov, TobiasBg, desrosj, azaozz.
Fixes #61782.

Built from https://develop.svn.wordpress.org/trunk@59192


git-svn-id: http://core.svn.wordpress.org/trunk@58587 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2024-10-07 21:13:16 +00:00
parent 8410b2fc26
commit a13d535628
2 changed files with 6 additions and 2 deletions

View File

@ -8833,7 +8833,11 @@ function clean_dirsize_cache( $path ) {
* @return string The current WordPress version.
*/
function wp_get_wp_version() {
require ABSPATH . WPINC . '/version.php';
static $wp_version;
if ( ! isset( $wp_version ) ) {
require ABSPATH . WPINC . '/version.php';
}
return $wp_version;
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-beta1-59191';
$wp_version = '6.7-beta1-59192';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.