Skip to content

Fatal error thrown on WP-CLI 2.8+ through SSH when using wp_remote_post from a plugin during a command. #5816

@jmtorres

Description

@jmtorres

Bug Report

--- ✅ If you are in the correct location now... --->

Describe the current, buggy behavior

When a plugin uses wp_remote_post during a wp-cli command, a fatal error is thrown related to the Request Response class. This appears to be related to the changes Request library changes wp-cli 2.8+. We are using the Decalog plugin with a Datadog logger. The plugin uses wp_remote_post to transmit logs after running a wp-cli command.

PHP Fatal error: Uncaught TypeError: WP_HTTP_Requests_Response::__construct(): Argument #1 ($response) must be of type Requests_Response, WpOrg\Requests\Response given, called in /www/public/wp-includes/class-wp-http.php on line 397 and defined in /www/public/wp-includes/class-wp-http-requests-response.php:42
Stack trace:
#0 /www/public/wp-includes/class-wp-http.php(397): WP_HTTP_Requests_Response->__construct()
#1 /www/public/wp-includes/class-wp-http.php(614): WP_Http->request()
#2 /www/public/wp-includes/http.php(179): WP_Http->post()
#3 /www/public/wp-content/plugins/decalog/includes/handlers/class-abstractbufferedhttphandler.php(109): wp_remote_post()
#4 /www/public/wp-content/plugins/decalog/includes/handlers/class-datadoghandler.php(56): Decalog\Handler\AbstractBufferedHTTPHandler->write()
#5 /www/public/wp-content/plugins/decalog/includes/handlers/class-datadoghandler.php(80): Decalog\Handler\DatadogHandler->write()
#6 /www/public/wp-content/plugins/decalog/includes/handlers/class-abstractbufferedhttphandler.php(144): Decalog\Handler\DatadogHandler->handleBatch()
#7 /www/public/wp-content/plugins/decalog/includes/handlers/class-abstractbufferedhttphandler.php(161): Decalog\Handler\AbstractBufferedHTTPHandler->flush()
#8 /www/public/wp-includes/class-wp-hook.php(305): Decalog\Handler\AbstractBufferedHTTPHandler->close()
#9 /www/public/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
#10 /www/public/wp-includes/plugin.php(474): WP_Hook->do_action()
#11 /www/public/wp-includes/load.php(1100): do_action()
#12 [internal function]: shutdown_action_hook()
#13 {main}
thrown in /www/public/wp-includes/class-wp-http-requests-response.php on line 42

Describe how other contributors can replicate this bug

  • Install Wordpress 5.9.5
  • Install Decalog 3.8.0
  • Configure a Datadog event logger
  • Run a command that generates a log captured by the Decalog Datadog logger

Describe what you expect as the correct outcome

The command completes without throwing a fatal error.

Let us know what environment you are running this on

OS: Linux 5.4.0-1108-gcp #117-Ubuntu SMP Tue Jun 20 23:26:26 UTC 2023 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php8.0
PHP version: 8.0.28
php.ini used: /etc/php/8.0/cli/php.ini
MySQL binary: /usr/bin/mysql
MySQL version: mysql Ver 15.1 Distrib 10.5.17-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
SQL modes:
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /www
WP-CLI packages dir:
WP-CLI cache dir: /www/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.8.1

Wordpress version: 5.9.5

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions