WordPress.org

Make WordPress Core

Opened 6 weeks ago

Last modified 6 weeks ago

#54589 new defect (bug)

Audit and preload current "from" version files into memory before upgrading filesystem to the "to" version

Reported by: hellofromTonya Owned by:
Milestone: 6.0 Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords: early has-patch has-unit-tests
Focuses: Cc:

Description

Follow-up to #54546.

Some terms for clarity:

  • current "from" version: the current version of WordPress on the site
  • new "to" version: the version of WordPress that the site will be upgraded to after the upgrade process is complete

The Problem

In the wp-admin/includes/update-core.php file, the filesystem is upgraded to the new "to" version before all of the upgrader process is completed.

What happens if the rest of the upgrader process doesn't yet have its code loaded into memory?

  • Fatal error, for example #54546
  • Unexpected behavior due to intermingling of "from" and "to" version of code

A fatal error happened in #54546 when cURL timed out and attempted to throw an exception when its file hadn't yet been loaded into memory. The exception class was changed, which would be handled by the "to" version autoloader but was not recognized by the "from" version autoloader in memory.

While #54546 is a specific instance, it revealed a fundamental problem in Core's upgrader.

The Goal

Ensure all files from the current ("from") version of WordPress that may be needed during the upgrade process are loaded into memory before upgrading the filesystem and database to the "to" version of WordPress.

Audit and Preload current "from" version files into memory

An audit will be needed to identify all of the files that are or could be used during the upgrade process, including alternative paths such as errors which may have dependencies.

A preloader mechanism will be needed capable of loading nested directories (such as loading an entire library or API into memory such as Requests) and individual files.

Consideration will be needed for:

  • differences in current "from" versions of files and code
  • possibly for downgrades from "to" version back to the "from" version
  • case-insensitive filesystems as identified in #54582

Props to @jrf, @pbiron, @costdev, @schlessera, @sergeybiryukov, and @mkaz for extensive investigation and testing.

Change History (3)

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


6 weeks ago

This ticket was mentioned in PR #2015 on WordPress/wordpress-develop by costdev.


6 weeks ago

  • Keywords has-patch has-unit-tests added

This PR implements a preloader for the upgrade process.

  • This is set to preload the wp-includes/Requests directory.
  • This is set to skip preloading wp-includes/Requests/Autoload.php on WP < 5.9.
  • These are in place as examples but should be part of the overall audit.

Source

  • [x] Allow preloading files.
  • [x] Allow recursively preloading directories.
  • [x] Allow skipping files from preloading.
  • [ ] Identify additional functionality that may be needed. Please identify in a review for discussion.
  • [ ] Identify additional functionality that may be helpful. Please suggest in a review for discussion.
  • [ ] Audit additional files needed by the upgrader.
  • [ ] Add the additional paths to the preloader, skipping individual files where necessary.

Tests

  • [x] Add initial tests to achieve 100% line/branch coverage.
  • [ ] If necessary, review the sample files implementation for an alternative.
  • [ ] Add more tests.
  • [ ] Manual testing.
  • [ ] Review documentation.

Trac ticket: https://core.trac.wordpress.org/ticket/54589

This ticket was mentioned in Slack in #core by jrf. View the logs.


6 weeks ago

Note: See TracTickets for help on using tickets.