Make WordPress Core

Opened 3 years ago

Closed 20 months ago

#53961 closed defect (bug) (reported-upstream)

InvalidArgumentException with wp_remote_post function

Reported by: hazem-elijla's profile Hazem Elijla Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.8
Component: External Libraries Keywords: reporter-feedback
Focuses: Cc:

Description

The folllowing code generates a PHP exception:
Overloaded object of type ... is not compatible with RecursiveArrayIterator.

I can't send array contains array or any other objects like Date

wp_remote_post( 'https://api.example.com/', [
	'body'   => [
		'name'       => 'Hazem',
		'email'      => 'hazem@example.com',
		'date'       => new DateTime( 'NOW' ),
		'additional' => [
			'example' => 1,
		]
	]
] );

After checking wp core code found that this line causing this issue.
seems like "RecursiveArrayIterator" doesn't support objects or arrays.

https://www.screencast.com/t/aZwVuWuZK

code located at:
https://github.com/WordPress/WordPress/blob/master/wp-includes/Requests/Transport/cURL.php

Change History (2)

#1 @jrf
3 years ago

  • Component changed from HTTP API to External Libraries
  • Keywords close added

Thanks for opening this ticket.

The Requests library is an external dependency of WordPress. Please report this issue upstream.

#2 @desrosj
20 months ago

  • Keywords reporter-feedback added; close removed
  • Milestone Awaiting Review deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed

I'm going to close this out, but please do follow up with a bug report on the Requests library repository with more details @hazem-elijla.

Note: See TracTickets for help on using tickets.