Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

WordPress shows a deprecation notice about Requests_ class names

Your error

Deprecated: The PSR-0 `Requests_...` class names in the Requests library are deprecated. Switch to the PSR-4 `WpOrg\Requests\...` class names at your earliest convenience.2 more lines it can show

Fix it fast

Most common cause, 1 of 3

Plugin or theme code still names Requests_ classes

If a third-party plugin is the source, update it, or ask its author for a release that uses the new names.

Fix
wp plugin update my-plugin
# own code, before:  catch ( Requests_Exception $e )
# own code, after:   catch ( WpOrg\Requests\Exception $e )
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

The notice that PSR-0 `Requests_...` class names are deprecated appears on WordPress 6.2 to 7.1 when a plugin or theme still calls old Requests_ classes or includes wp-includes/class-requests.php. Update that plugin, or rename its calls to the WpOrg\Requests namespace. On a live site, send notices to debug.log with WP_DEBUG_LOG and turn WP_DEBUG_DISPLAY off.

  • Applies to WordPress 7.1.5 (Requests 2.0.17 bundled), WordPress 6.2 and later, PHP 7.4 or later (WordPress minimum), WP-CLI wp plugin update
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Search the plugins, themes and must-use plugins for the old class names and for the deprecated file. Hits on Requests_ names mean cause 1; a hit on class-requests.php means cause 2. Run it from the WordPress root.

Run this first
grep -rnE "Requests_[A-Z][A-Za-z_]*|class-requests\.php" wp-content/plugins wp-content/themes wp-content/mu-plugins

Then find the line you see in this list and open its fix:

  1. 1Plugin or theme code still names Requests_ classesgrep prints lines such as catch ( Requests_Exception $e ) or new Requests_Response inside one plugin folder
  2. 2Code requires the old wp-includes/class-requests.php filegrep finds require or include with class-requests.php, and the notice fires on every request, even pages that make no HTTP call
  3. 3Debug output is switched on for the live siteThe notice prints at the top of pages or inside admin screens, and wp-config.php sets WP_DEBUG to true

What does the error look like?

  • Deprecated: The PSR-0 `Requests_...` class names in the Requests library are deprecated. Switch to the PSR-4 `WpOrg\Requests\...` class names at your earliest convenience.
  • wp-includes/class-requests.php
  • wp-includes/Requests/src/Autoload.php

Cause 1 of 3

Plugin or theme code still names Requests_ classes

You seegrep prints lines such as catch ( Requests_Exception $e ) or new Requests_Response inside one plugin folder

Check

WordPress 6.2 moved the bundled Requests library to version 2, which puts every class in the WpOrg\Requests namespace. Old names like Requests_Exception still work through an alias, but the core autoloader raises the PSR-0 deprecation notice the first time one is used.

Check
grep -rln "Requests_" wp-content/plugins wp-content/themes | cut -d/ -f1-3 | sort -u

Fix

If a third-party plugin is the source, update it, or ask its author for a release that uses the new names. In code you own, swap each old name for its namespaced class, for example Requests_Exception becomes WpOrg\Requests\Exception.

Fix
wp plugin update my-plugin
# own code, before:  catch ( Requests_Exception $e )
# own code, after:   catch ( WpOrg\Requests\Exception $e )

Verify

Load the page that showed the notice. No new deprecation line is added to wp-content/debug.log.

Verify
tail -n 20 wp-content/debug.log

Confirmed by make.wordpress.org

Did this fix it?

Cause 2 of 3

Code requires the old wp-includes/class-requests.php file

You seegrep finds require or include with class-requests.php, and the notice fires on every request, even pages that make no HTTP call

Check

Since 6.2, wp-includes/class-requests.php is a deprecated shim. Its first lines trigger the same E_USER_DEPRECATED notice as soon as the file is loaded, before any class is used.

Check
grep -rn "class-requests.php" wp-content/

Fix

Delete the include. WordPress core loads the library itself: class-wp-http.php requires Requests/src/Autoload.php and registers it when WpOrg\Requests\Autoload is not yet defined. Code that runs earlier can use that same guarded block.

Fix
if ( ! class_exists( 'WpOrg\Requests\Autoload' ) ) {
    require ABSPATH . WPINC . '/Requests/src/Autoload.php';
    WpOrg\Requests\Autoload::register();
}

Verify

The grep for class-requests.php returns nothing and the notice is gone from new page loads.

Verify
grep -rn "class-requests.php" wp-content/ || echo clean

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 3 of 3

Debug output is switched on for the live site

You seeThe notice prints at the top of pages or inside admin screens, and wp-config.php sets WP_DEBUG to true

Check

Deprecation notices only reach the browser when WP_DEBUG is true and WP_DEBUG_DISPLAY keeps its default of true. The old names keep working through the alias, yet visitors should never see the message.

Check
grep -nE "WP_DEBUG|display_errors|REQUESTS_SILENCE" wp-config.php

Fix

Write notices to a log file and hide them from pages. While you wait for a plugin update, wp-config.php can also define REQUESTS_SILENCE_PSR0_DEPRECATIONS as true; it must exist before the first old class is requested.

Fix
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
// stopgap until the plugin is updated
define( 'REQUESTS_SILENCE_PSR0_DEPRECATIONS', true );

Verify

Pages render with no notice text, and real errors still land in wp-content/debug.log.

Verify
ls -l wp-content/debug.log

Confirmed by developer.wordpress.org

Did this fix it?

How do I stop it coming back?

  • Run a staging copy with WP_DEBUG_LOG on after each core or plugin update, and scan debug.log for new deprecation lines.
  • In custom plugins, call the Requests library only through WpOrg\Requests names and never include files from wp-includes by path.
  • Remove the REQUESTS_SILENCE_PSR0_DEPRECATIONS line once the plugin that needed it ships a fixed release.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: Spotless Laundry, EZ Estimater.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.