[wp-trac] [WordPress Trac] #28601: wp.newPost fatals when a post_date field is included in the data

WordPress Trac noreply at wordpress.org
Fri Jun 20 14:27:58 UTC 2014


#28601: wp.newPost fatals when a post_date field is included in the data
--------------------------+-----------------------------
 Reporter:  dllh          |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  XML-RPC       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 In `_insert_post()`, we assume that `$post_data['post_date']` and
 `$post_data['post_date_gmt']` are already `IXR_Date` objects, when they're
 not. These are converted in the `wp_editPost()` function but are not
 converted either in `wp_newPost()` or in `_insert_post()`. The result is
 that if you submit an xmlrpc request that includes `post_date` or
 `post_date_gmt`, you get this fatal error:

 Fatal error: Call to a member function getIso() on a non-object in /root
 /wordpress-develop/src/wp-includes/class-wp-xmlrpc-server.php on line 1200

 I'm attaching a patch that fixes it and a couple of unit tests that
 demonstrate the error. To repro:

 1. Apply the unit test patch but not the xmlrpc patch.
 2. Run the tests.

 You'll see the fatal error as the tests run. Apply the xmlrpc patch and
 run the tests again, and the error is gone.

 I've basically copied the method that was already being used in
 `wp_editPost()`, with some checks for existence of the data added, since
 there's not a certainty that it'll be submitted.

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


More information about the wp-trac mailing list