Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish date uses draft create date and not updated on publish #7195

Closed
mkaz opened this issue Jun 6, 2018 · 4 comments
Closed

Publish date uses draft create date and not updated on publish #7195

mkaz opened this issue Jun 6, 2018 · 4 comments
Assignees
Labels
[Feature] Saving Related to saving functionality

Comments

@mkaz
Copy link
Member

mkaz commented Jun 6, 2018

Describe the bug

When creating a draft several days ahead of time, and then publishing the post will keep the same early draft date and not use the date it was published.

To Reproduce
Steps to reproduce the behavior:

  1. Create a draft a day or more ahead
  2. Publish post a day or more after
  3. Check the date of the publish post, it will be the initial draft date

Expected behavior

Unless the date gets set specifically, I expect the publish date to be the date it is published, not the date when the draft was created.

@mtias mtias added the [Feature] Saving Related to saving functionality label Jul 19, 2018
@earnjam
Copy link
Contributor

earnjam commented Jul 31, 2018

So it looks like what actually gets stored is the current date, but what gets displayed on the publish confirmation is the original draft created date. See screenshots below for workflow.

Draft created July 29, then later published on July 31:

Posts screen showing older date

screen shot 2018-07-31 at 9 50 18 am

Editing the older draft post in Gutenberg

(Current date is July 31)
screen shot 2018-07-31 at 9 50 30 am

Click Publish

This is the one that is confusing because that is not the publish date that is going to be used.

screen shot 2018-07-31 at 9 50 38 am

Posts list after publishing

Publish date now accurately reflects the date/time the publish button was actually clicked.

screen shot 2018-07-31 at 9 50 54 am

Viewing published post on the front-end

screen shot 2018-07-31 at 9 51 11 am

@earnjam earnjam self-assigned this Jul 31, 2018
@earnjam
Copy link
Contributor

earnjam commented Aug 2, 2018

So after some further research, this just appears to be more of a labeling issue than an actual saving problem.

When first creating a post, the publish panel shows the Publish date as the time that the post was created or a draft was saved. It should show Publish: Immediately until a date is manually set, or the post is actually published.

This is confusing because the date being shown is not necessarily what will be used and saved when published.

The reason for this is somewhat convoluted. Internally WordPress uses a date_gmt value of 0000-00-00 00:00:00 to indicate that a draft's date is floating and should be updated/set when saved. However, this made getting accurate dates difficult for clients using the REST API because they'd have to do some timezone manipulation. So a shim was put in for post_date_gmt to force a best guess value for date_gmt in the REST API response (See trac ticket #38883). This is problematic in Gutenberg because we can't determine if a draft post has a date set or not.

Fixing will require a modification to the REST API to allow null for date_gmt when it's not set. To ensure back compatibility, we can just do it when the edit context is passed. It will also require a small change to the PostScheduleLabel component to take into consideration that date_gmt value.

@earnjam
Copy link
Contributor

earnjam commented Aug 2, 2018

Another proposed REST API solution is adding a date_floating flag. https://core.trac.wordpress.org/ticket/39953

@earnjam
Copy link
Contributor

earnjam commented Oct 18, 2018

I think any remaining issue here was resolved with #9967

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Saving Related to saving functionality
Projects
None yet
Development

No branches or pull requests

3 participants