Make WordPress Core

Opened 18 months ago

Closed 18 months ago

Last modified 18 months ago

#57662 closed defect (bug) (fixed)

Fatal Error: _preload_old_requests_classes_and_interfaces() when updating from WordPress older than 4.6

Reported by: afragen's profile afragen Owned by: hellofromtonya's profile hellofromTonya
Milestone: 6.2 Priority: normal
Severity: normal Version: 6.2
Component: Upgrade/Install Keywords: has-testing-info has-patch commit
Focuses: Cc:

Description

During the 6.2-beta1 release party I got the following error (see image).

I'm using a local test site just for the release party. I was on 6.1.1 and used Core Rollback to revert to 4.0.38. I have WordPress Beta Tester set to 'Bleeding Edge' and 'Beta/RC'.

I initially tried 4.038, 4.1.37 both initially failed. The I updated from 5.9.5 and worked my way back down the releases from each major. I retried the first 2 again and they passed.

Core Rollback and WordPress Beta Tester at current releases used.

Attachments (1)

6.2-beta1-update-error.png (150.3 KB) - added by afragen 18 months ago.

Download all attachments as: .zip

Change History (16)

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


18 months ago

#2 @johnbillion
18 months ago

  • Component changed from General to Upgrade/Install
  • Milestone changed from Awaiting Review to 6.2
  • Version set to trunk

#3 @costdev
18 months ago

  • Keywords has-testing-info added

Testing Instructions

These steps define how to reproduce the issue, and indicate the expected behavior.

Steps to Reproduce

  1. Use PHP 5.6.
  2. Set up a 6.1.1 site.
  3. Enable WP_DEBUG, WP_DEBUG_LOG and WP_DEBUG_DISPLAY in wp-config.php.
  4. Install and activate the Core Rollback and WordPress Beta Tester plugins.
  5. Navigate to Tools > Rollback Core.
  6. Select 4.0.38 from the <select> element and click Rollback.
  7. Navigate to Dashboard > Updates and click Re-install 4.0.38.
  8. Navigate to Tools > Beta Testing.
  9. Select Bleeding Edge and Beta/RC only. Click Save Changes.
  10. 🐞 Navigate to Dashboard > Updates and click Update now.

Expected Results

When testing a patch to validate it works as expected:

  • ✅ There is no fatal error.

When reproducing a bug:

  • ❌ There is a fatal error:

Fatal error:
Class 'Requests_Exception' not found in /site/path/wp-includes/Requests/Exception/HTTP.php on line 13

Last edited 18 months ago by costdev (previous) (diff)

#4 @costdev
18 months ago

  • Keywords needs-patch added

Requests was introduced in WordPress 4.6, see #33055.

Looks like we need a minimum version check in _preload_old_requests_classes_and_interfaces().

Preparing a patch now.

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


18 months ago
#5

  • Keywords has-patch added; needs-patch removed

The Requests library was introduced in WordPress 4.6.

Attempting to preload the Requests 1.x classes/interfaces in earlier versions of WordPress
causes a fatal error.

This skips preloading if the website previously used a WordPress version earlier than 4.6.

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

#6 @ironprogrammer
18 months ago

Test Report

Patch tested: https://github.com/WordPress/wordpress-develop/pull/4029

To test the patch, refer to these custom update package test instructions.

Environment

  • Hardware: iMac
  • OS: macOS 12.6.2
  • Browser: Safari 16.2
  • Server: Apache/2.4.55 (Unix) PHP/5.6.40
  • PHP: 5.6.40
  • WordPress: 6.1.1
  • Theme: twentytwentyone v1.6
  • Active Plugins:
    • core-rollback v1.3.4
    • wordpress-beta-tester v3.2.7
    • fake-wordpress-update (see the test instructions above)

Actual Results

When reproducing a bug:

  • "Fatal error: Class 'Requests_Exception'" occurred when attempting to update.

When testing a patch to validate it works as expected:

  • Using a patched build package, the update to 6.2-beta1 succeeded without error.

Additional Notes

  • In test Step 2, ensure that a classic theme is active. I was unable to roll back past 5.9 with a block theme active.
  • For clarity, the fatal error that occurred prevented the update, but did leave the site in a usable state (i.e. I was able to then test the patched build).
Last edited 18 months ago by ironprogrammer (previous) (diff)

#7 @antonvlasenko
18 months ago

Test Report

Patch tested: https://github.com/WordPress/wordpress-develop/pull/4029

Test instructions provided by @ironprogrammer: https://gist.github.com/ironprogrammer/1aaff6f60b263c1842e3584365729ffc

Environment

  • Hardware: Mac mini M1
  • wp-env
  • OS: macOS 13.1
  • PHP: 5.6.39
  • WordPress: 6.2-beta1
  • Browser: Safari 16.2
  • Theme: Twenty Twelve
  • Active Plugins:
    • core-rollback v1.3.4
    • wordpress-beta-tester v3.2.7
    • fake-wordpress-update (see the test instructions above)

Actual Results

When reproducing a bug:

  • ❌ "Fatal error: Class 'Requests_Exception'" occurred when attempting to update.

https://cldup.com/KmAMF2VzV5.png
When testing a patch to validate it works as expected:

  • ✅ No errors when updating to the patched version of WordPress.

https://cldup.com/FVzpoosr_z.png

Notes

If you are testing the patch on wp-env:

  1. You may need to use this workaround to install WordPress on PHP 5.6: https://github.com/WordPress/gutenberg/issues/40745#issuecomment-1422471660
  2. Also, when creating a custom WordPress package, you will need to upload it to a server accessible from the Internet (I used GitHub). Otherwise, WordPress will not see it (due to wp-env).
Last edited 18 months ago by antonvlasenko (previous) (diff)

#8 @hellofromTonya
18 months ago

  • Owner set to hellofromTonya
  • Status changed from new to reviewing

Currently reviewing for commit.

#9 @hellofromTonya
18 months ago

  • Keywords commit added

https://github.com/WordPress/wordpress-develop/pull/4029

  • 2 Test Reports ✅
  • Resolves the reported issue ✅
  • Bails out immediately to skip Requests preloading logic ✅

Ready for commit 👍

#10 @hellofromTonya
18 months ago

Prepping commit now.

#11 @hellofromTonya
18 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 55296:

Upgrade/Install: Skip preloading Requests for WordPress versions before 4.6.

Skip preloading Requests files in _preload_old_requests_classes_and_interfaces() when updating from a WordPress version older than 4.6.

Why?

Requests library was first introduced into WordPress 4.6 via #33055 / [37428]. If a user is upgrading from a version older than 4.6, this changeset prevents the Requests preloading to prevent a fatal error of attempting to load files that do not exist in their current WordPress version.

Follow-up to [54997], [37428].

Props afragen, costdev, ironprogrammer, antonvlasenko.
Fixes #57662.

#13 @hellofromTonya
18 months ago

  • Summary changed from Error from _preload_old_requests_classes_and_interfaces on update from 4.0.38 to 6.2-beta1 to Fatal Error: _preload_old_requests_classes_and_interfaces() when updating from WordPress older than 4.6

Renamed for the root cause.

#14 @peterwilsoncc
18 months ago

For upgrades from 4.5 and earlier, does the previous library need to be pre-loaded in a similar fashion?

I suspect the answer is no but I'd sure feel silly if I didn't ask and it became a problem.

#15 @afragen
18 months ago

Since Requests was first introduced in 4.6, it's not necessary to pre-load anything prior to that. At least that's my understanding.

Note: See TracTickets for help on using tickets.