Make WordPress Core

Opened 5 weeks ago

Closed 5 weeks ago

Last modified 5 weeks ago

#62165 closed defect (bug) (fixed)

New wp_get_wp_version() might not be available during update

Reported by: djennez's profile djennez Owned by: azaozz's profile azaozz
Milestone: 6.7 Priority: normal
Severity: critical Version: trunk
Component: Upgrade/Install Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Hi all!

I hope I was able to debug / hypothesize this issue correctly.

In #61627 a new method wp_get_wp_version() was introduced and simultaneously used in src/wp-admin/includes/update-core.php for _preload_old_requests_classes_and_interfaces().

I think the new function is not yet loaded correctly during the update process because updating from a stable WordPress version to Nightly, either via WP-CLI or via the WordPress Beta Tester plugin, causes an Error.

Log and stacktrace from WP-CLI:

Updating to version nightly (en_US)...
Downloading update from https://wordpress.org/nightly-builds/wordpress-latest.zip...
Unpacking the update...
[04-Oct-2024 07:58:08 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function wp_get_wp_version() in /var/www/html/wp-admin/includes/update-core.php:1547
Stack trace:
#0 /var/www/html/wp-admin/includes/update-core.php(980): _preload_old_requests_classes_and_interfaces('/var/www/html/')
#1 /var/www/html/wp-admin/includes/class-core-upgrader.php(174): update_core('/var/www/html/w...', '/var/www/html/')
#2 phar:///usr/local/bin/wp/vendor/wp-cli/core-command/src/WP_CLI/Core/CoreUpgrader.php(159): Core_Upgrader->upgrade(Object(stdClass), Array)
#3 phar:///usr/local/bin/wp/vendor/wp-cli/core-command/src/Core_Command.php(1193): WP_CLI\Core\CoreUpgrader->upgrade(Object(stdClass))
#4 [internal function]: Core_Command->update(Array, Array)
#5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func(Array, Array, Array)
#6 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#7 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(497): call_user_func(Object(Closure), Array, Array)
#8 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(441): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#9 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(464): WP_CLI\Runner->run_command(Array, Array)
#10 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1296): WP_CLI\Runner->run_command_and_exit()
#11 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start()
#12 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(83): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#13 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(32): WP_CLI\bootstrap()
#14 phar:///usr/local/bin/wp/php/boot-phar.php(20): include('phar:///usr/loc...')
#15 /usr/local/bin/wp(4): include('phar:///usr/loc...')
#16 {main}
  thrown in /var/www/html/wp-admin/includes/update-core.php on line 1547
Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.

Reproduction steps:

  1. Run WordPress 6.6.2
  2. (Option A) Attempt to update via WP-CLI with the following command: wp core update '--version=nightly' --force
  3. (Option B) Attempt to update to nightly using the `WordPress Beta Tester` plugin (make sure to set it to update from Bleeding Edge and not Stable point).
  4. Notice the fatal error.

Note: Attempting an update puts the site in an update lock state, this WP-CLI command should resolve that:
wp option delete core_updater.lock

Change History (9)

#1 @SergeyBiryukov
5 weeks ago

  • Description modified (diff)
  • Milestone changed from Awaiting Review to 6.7

#2 @SergeyBiryukov
5 weeks ago

  • Description modified (diff)

#3 follow-up: @jorbin
5 weeks ago

  • Severity changed from normal to critical

I've tested and confirmed this. Upgrading the severity since I think this should block beta 2 as folks won't be able to upgrade to beta 2 without already being on [58813] or later.

As for the fix, I think we should do a require ABSPATH . WPINC. '/version.php'; in the two places in wp-admin/includes/update-core.php that were modified in [59159].

cc/ @peterwilsoncc, @hellofromtonya @davidbaumwald.

#4 in reply to: ↑ 3 @azaozz
5 weeks ago

Replying to jorbin:

As for the fix, I think we should do a require ABSPATH . WPINC. '/version.php'; in the two places in wp-admin/includes/update-core.php that were modified in [59159].

Right, if I remember correctly when WP is being updated the new update-core.php runs in the old version so it cannot contain calls to newly introduced functions. Removing the two calls to wp_get_wp_version() would fix this.

Last edited 5 weeks ago by azaozz (previous) (diff)

#5 @peterwilsoncc
5 weeks ago

Here's a run of the upgrade tests failing. Yes, let's revert the changes in the most recent commit for the upgrades.

If no one else gets to it, I'll prep a patch by Monday to commit prior to the second beta on Tuesday (AU time).

This ticket was mentioned in Slack in #core-upgrade-install by azaozz. View the logs.


5 weeks ago

#7 @azaozz
5 weeks ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 59180:

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.

#8 @azaozz
5 weeks ago

In 59182:

Docs: Fix note about not using new functions in update-core.php and class-core-upgrader.php.

Props costdev.
See #62165.

#9 @peterwilsoncc
5 weeks ago

Thanks Ozz, this is a run of the upgrade tests passing after the commits above.

Note: See TracTickets for help on using tickets.