WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#10244 closed defect (bug) (fixed)

metaWeblog.getPost XML-RPC method should return the correct date/time for the date_created_gmt field for draft posts

Reported by: josephscott Owned by: josephscott
Milestone: 2.8.5 Priority: normal
Severity: normal Version: 2.8
Component: XML-RPC Keywords: has-patch
Focuses: Cc:

Description

Because WP uses post_date_gmt database field internally to trigger certain events draft posts don't get a valid date/time (it uses 0000-00-00 00:00:00), but they do get a valid post_date entry in the DB.

XML-RPC clients run into problems when calling metaWeblog.getPost on drafts because of this. The dateCreated field uses the DB post_date field for the draft and the date_created_gmt uses the post_date_gmt DB field. So the response has dateCreated with a valid date and date_created_gmt with some screwy date (usually 1969 or 1999).

Seems the more correct thing to do would be to provide the right GMT date/time in the date_created_gmt field for drafts. I'm including a patch that will populate the date_created_gmt field when metaWeblog.getPost is called on a draft by calling get_gmt_from_date() and then tweaking the result to be correctly formatted for the XML-RPC response.

I consider this a bug and would like to see it get into the 2.8.1 release.

Attachments (2)

xmlrpc.php.diff (775 bytes) - added by josephscott 6 years ago.
xmlrpc.php.2.diff (3.0 KB) - added by josephscott 6 years ago.

Download all attachments as: .zip

Change History (10)

@josephscott6 years ago

comment:1 @ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [11625]) Return correct date in date_created_gmt field. Props josephscott. fixes #10244 for 2.8.1

comment:3 @josephscott6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I'm re-opening this ticket because there are other methods that return an invalid date/time for the date_created_gmt field for drafts. I've gone through and updated all of these locations to provide a valid value based post_date, but only if the post_status is draft.

@josephscott6 years ago

comment:4 @josephscott6 years ago

This should also go into the 2.8 branch, if there's another release from there it will be good to get these included.

comment:5 @westi6 years ago

Can we not extend get_gmt_from_date to take a format string as a second parameter rather than having all that copy&paste code!

comment:6 @westi6 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [11846]) Ensure that drafts viewed over XMLRPC have a correct gmt date set. Fixes #10244 for trunk props josephscott.

comment:7 @westi6 years ago

  • Milestone changed from 2.8.1 to 2.8.5
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopen for 2.8 branch

comment:8 @westi6 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [11847]) Ensure that drafts viewed over XMLRPC have a correct gmt date set. Fixes #10244 for 2.8 branch props josephscott.

Note: See TracTickets for help on using tickets.