[wp-trac] [WordPress Trac] #35874: XMLRPC: Draft posts are published immediately when changed to published and future-dated at once

WordPress Trac noreply at wordpress.org
Fri Feb 19 18:19:02 UTC 2016


#35874: XMLRPC: Draft posts are published immediately when changed to published and
future-dated at once
--------------------------+------------------------------
 Reporter:  redsweater    |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  XML-RPC       |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by redsweater):

 OK, updated analysis good as of just now with latest trunk: the problem
 specifically applies to clients who specify the date with "date_created"
 and leave "date_created_gmt" empty. MarsEdit is one such client.

 The problematic code is here, in wp_insert_post():

 {{{
 if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' ==
 $postarr['post_date_gmt'] ) {
         if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-
 draft' ) ) ) {
                 $post_date_gmt = get_gmt_from_date( $post_date );
         } else {
                 $post_date_gmt = '0000-00-00 00:00:00';
         }
 } else {
         $post_date_gmt = $postarr['post_date_gmt'];
 }
 }}}

 The problem this date resetting code hinges on the presence of
 'post_date_gmt' which may be absent. In fact, code just prior to this
 block has standardized and validated the date by assigning to $post_date a
 value that is either taken directly from $postarr['post_date'] or else
 derived from $postarr['post_date_gmt'].

 At this point the canonical date for any further validation or date-reset
 logic should be the value in the local $post_date variable.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35874#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list