From 429829d6d91fac1b9870eb2a989c2a02649f48f9 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Mon, 19 Dec 2022 15:10:20 +0000 Subject: [PATCH] HTTP API: Adds BC-layer `/library/Requests.php` file. When the Requests 2.0.0 [https://github.com/WordPress/Requests/blob/7ef0774f0bf32dddb7b6c1dd01e4d285c2ba3c3f/src/Autoload.php#L141-L143 autoloader detects the older (deprecated) `Requests` class], it attempts to load [https://github.com/WordPress/Requests/blob/v2.0.0/library/Requests.php its `/library/Requests.php` file]. Prior to this commit, this file did not exist in Core. Thus, a fatal error happened. Why not change Requests Autoloader? Requests is an external dependency that Core consumes. It is also used by other projects outside of Core. Thus, Core needs a fix to guard itself to prevent a fatal error. The fix: * Adds the missing `wp-includes/Requests/library/Requests.php` file, which then loads the `wp-includes/class-requests.php` (which will throw a deprecation notice to alert developers to upgrade). * Adds a test. Follow-up to [54997]. Props bjorsch, costdev, jrf, mukesh27, peterwilsoncc, ironprogrammer, hellofromTonya. Fixes #57341. git-svn-id: https://develop.svn.wordpress.org/trunk@55007 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/Requests/library/Requests.php | 12 ++++++++++ .../tests/http/includeOldRequestsClass.php | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/wp-includes/Requests/library/Requests.php create mode 100644 tests/phpunit/tests/http/includeOldRequestsClass.php diff --git a/src/wp-includes/Requests/library/Requests.php b/src/wp-includes/Requests/library/Requests.php new file mode 100644 index 0000000000..9e42db596b --- /dev/null +++ b/src/wp-includes/Requests/library/Requests.php @@ -0,0 +1,12 @@ +expectDeprecation(); + $this->expectDeprecationMessage( 'The PSR-0 `Requests_...` class names in the Request library are deprecated.' ); + + new Requests(); + } +}