[wp-trac] [WordPress Trac] #57341: `Error: Class "Requests" not found` in trunk

WordPress Trac noreply at wordpress.org
Fri Dec 16 15:11:44 UTC 2022


#57341: `Error: Class "Requests" not found` in trunk
--------------------------+-----------------------------
 Reporter:  bjorsch       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  HTTP API      |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 With the merge of the updated Requests library (thank you!), there's one
 thing that seems to have remained broken. Use of the old `Requests` class
 does not work since that class is not loaded by the new library's
 autoloader like everything else is.

 The problem seems to be in
 [https://github.com/WordPress/WordPress/blob/b1f7eb6e1e5fae99091fb999de10adfe0fa87973
 /wp-includes/Requests/src/Autoload.php#L141-L143 wp-
 includes/Requests/src/Autoload.php lines 141–143]:
 {{{#!php
 if ($class_lower === 'requests') {
         // Reference to the original PSR-0 Requests class.
         $file = dirname(__DIR__) . '/library/Requests.php';
 }}}
 It tries, but it uses the wrong file path because the necessary file is in
 a different place in WordPress versus the Requests library. If that last
 line is changed to this
 {{{#!php
         $file = dirname(dirname(__DIR__)) . '/class-requests.php';
 }}}
 then it works.

 I have no idea whether you'll want to fix this in WordPress core or in the
 Requests library somehow to sync back into core, so I'll leave it to you
 to produce the patch.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57341>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list