From 3d591078b532368b401e8495f3f1a4d209e236e5 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sat, 5 Oct 2024 22:49:43 +0000 Subject: [PATCH] General: Do not use the new `wp_get_wp_version()` in `update-core.php` and `class-core-upgrader.php`. All functions that are used there must be present in both the previous version being upgraded from, and the later version that's being installed (e.g. when rolling back Core) as these files are used in both. Props djennez, SergeyBiryukov, jorbin, peterwilsoncc, azaozz. Fixes #62165. See 61627. git-svn-id: https://develop.svn.wordpress.org/trunk@59180 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-core-upgrader.php | 9 +++++++-- src/wp-admin/includes/update-core.php | 15 ++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/wp-admin/includes/class-core-upgrader.php b/src/wp-admin/includes/class-core-upgrader.php index 0629e0b8e1286..7c1d5e9c10ba1 100644 --- a/src/wp-admin/includes/class-core-upgrader.php +++ b/src/wp-admin/includes/class-core-upgrader.php @@ -13,6 +13,11 @@ * It allows for WordPress to upgrade itself in combination with * the wp-admin/includes/update-core.php file. * + * Note: newly introduced functions and methods cannot be used here. + * All functions must be present in both the previous version being upgraded from, + * and the later version that's being installed (e.g. when rolling back Core) + * as this file is used in both. + * * @since 2.8.0 * @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader.php. * @@ -391,13 +396,13 @@ public static function should_update_to_version( $offered_ver ) { * * @since 3.7.0 * + * @global string $wp_version The WordPress version string. * @global string $wp_local_package Locale code of the package. * * @return bool True if the checksums match, otherwise false. */ public function check_files() { - global $wp_local_package; - $wp_version = wp_get_wp_version(); + global $wp_version, $wp_local_package; $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' ); diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 639faba22478a..1a814aa5f8097 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -2,6 +2,11 @@ /** * WordPress core upgrade functionality. * + * Note: newly introduced functions and methods cannot be used here. + * All functions must be present in both the previous version being upgraded from, + * and the later version that's being installed (e.g. when rolling back Core) + * as this file is used in both. + * * @package WordPress * @subpackage Administration * @since 2.7.0 @@ -1539,12 +1544,12 @@ function update_core( $from, $to ) { * * @global array $_old_requests_files Requests files to be preloaded. * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. + * @global string $wp_version The WordPress version string. * * @param string $to Path to old WordPress installation. */ function _preload_old_requests_classes_and_interfaces( $to ) { - global $_old_requests_files, $wp_filesystem; - $wp_version = wp_get_wp_version(); + global $_old_requests_files, $wp_filesystem, $wp_version; /* * Requests was introduced in WordPress 4.6. @@ -1587,14 +1592,14 @@ function _preload_old_requests_classes_and_interfaces( $to ) { * * @since 3.3.0 * - * @global string $pagenow The filename of the current screen. + * @global string $wp_version The WordPress version string. + * @global string $pagenow The filename of the current screen. * @global string $action * * @param string $new_version */ function _redirect_to_about_wordpress( $new_version ) { - global $pagenow, $action; - $wp_version = wp_get_wp_version(); + global $wp_version, $pagenow, $action; if ( version_compare( $wp_version, '3.4-RC1', '>=' ) ) { return;