[wp-trac] [WordPress Trac] #23474: wp_update_post returns incorrect WP_Error on invalid ID (if $wp_error is set)

WordPress Trac noreply at wordpress.org
Thu Feb 14 12:24:28 UTC 2013


#23474: wp_update_post returns incorrect WP_Error on invalid ID (if $wp_error is
set)
------------------------------------+--------------------------
 Reporter:  simonwheatley           |       Type:  defect (bug)
   Status:  new                     |   Priority:  normal
Milestone:  Awaiting Review         |  Component:  General
  Version:  3.5                     |   Severity:  normal
 Keywords:  has-patch dev-feedback  |
------------------------------------+--------------------------
 {{{
 $post_data = array(
         'ID' => 999, // Does not exist
         'post_title' => 'Test title',
 );
 $res = wp_update_post( $post_data, true );
 error_log( $res->get_error_message() ); // 'Content, title, and excerpt
 are empty.'
 }}}

 The error is misleading, and further an `array_merge` notice is thrown as
 the `null` returned by `get_post` is not an array.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23474>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list