From 12991d53a46874aff10041f969ae2df22d5df8a3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 29 Jul 2024 15:02:17 +0000 Subject: [PATCH] General: Memoize the return value in `wp_get_wp_version()`. This aims to optimize performance by saving the return value to a static variable, so that the `version.php` file is not unnecessarily required on each function call. Follow-up to [58813]. Props Cybr, debarghyabanerjee, mukesh27. Fixes #61782. See #61627. Built from https://develop.svn.wordpress.org/trunk@58827 git-svn-id: http://core.svn.wordpress.org/trunk@58223 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index a884303893..136012dd07 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -8819,7 +8819,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; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 0516a247ac..252cbbf981 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-alpha-58826'; +$wp_version = '6.7-alpha-58827'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.