Skip to content

Commit

Permalink
General: Do not use the new wp_get_wp_version() in `update-core.php…
Browse files Browse the repository at this point in the history
…` 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
  • Loading branch information
azaozz committed Oct 5, 2024
1 parent 6c285f0 commit 3d59107
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/wp-admin/includes/class-core-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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' );

Expand Down
15 changes: 10 additions & 5 deletions src/wp-admin/includes/update-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3d59107

Please sign in to comment.