[wp-trac] [WordPress Trac] #53961: InvalidArgumentException with wp_remote_post function

WordPress Trac noreply at wordpress.org
Thu Aug 19 19:05:21 UTC 2021


#53961: InvalidArgumentException with wp_remote_post function
--------------------------+-----------------------------
 Reporter:  Hazem Elijla  |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  HTTP API      |    Version:  5.8
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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 at 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.

 [[Image(https://www.screencast.com/t/aZwVuWuZK)]]

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

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


More information about the wp-trac mailing list