WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#5698 closed defect (bug) (fixed)

Set timestamps for unpublished posts

Reported by: ryan Owned by: ryan
Milestone: 2.7 Priority: normal
Severity: normal Version: 2.3.2
Component: Administration Keywords: date time
Focuses: Cc:

Description

Currently, we don't set timestamps for unpublished posts. This
results in drafts not ordering nicely by date and causes some
confusion among users. Empty timestamps are done mainly to
accommodate history bloggers who like to set their timestamps in the
past. We don't want to stomp their choice once they've made it.
There is another way, however, that will inconvenience them only
slightly while allowing us to provide real timestamps for drafts.

The edit post page has an "Edit Timestamp" checkbox. If checked, the
timestamp specified in the input boxes is given to the draft. This
timestamp sticks with it through publication. If "Edit Timestamp" is
never checked during save, the draft will have an empty timestamp
until published. We could turn the "Edit Timestamp" checkbox on its
head and call it "Reset to current time". This would be checked by
default for unpublished posts and unchecked for published and future
posts. If someone sets the time on their draft and wants it to stick,
they must uncheck "Reset to current time" every time they save. If
someone edits the timestamp, we uncheck reset to current time for them
and set a "use this edited time" flag.

Attachments (2)

modified.diff (438 bytes) - added by ryan 7 years ago.
Make sure drafts have modified time set
5698.diff (1.5 KB) - added by ryan 6 years ago.

Download all attachments as: .zip

Change History (20)

comment:1 @lloydbudd7 years ago

"Set to current time"

The new experience sounds a little unfamilar to most people, but it is a problem worth solving and I don't have a better solution.

comment:2 follow-up: @filosofo7 years ago

Why don't we instead leave the post_date alone (unset for drafts) but set the post_modified to reflect when a draft has been saved. Then we can sort drafts by post_modified.

comment:3 in reply to: ↑ 2 @filosofo7 years ago

Replying to filosofo:

Why don't we instead leave the post_date alone (unset for drafts) but set the post_modified to reflect when a draft has been saved. Then we can sort drafts by post_modified.

Now that I look at the code, I see that this is the current behavior. So why do you say that the current behavior "results in drafts not ordering nicely by date and causes some confusion among users"? Whatever was saved most recently shows up first--isn't that what you'd expect?

comment:4 @ryan7 years ago

post_modified isn't set until a draft is saved a second time. We should fix that.

Manage->Posts sorts by modified only when showing drafts, not when showing all. When looking at all posts, it would be nice to see the drafts sorted in with published posts instead of lumped the end. Right now, you can't see the draft post you just saved if Manage->Posts is paged unless you know to filter on drafts.

@ryan7 years ago

Make sure drafts have modified time set

comment:5 follow-up: @ryan7 years ago

Patch makes sure drafts have a modified time. That helps a bit.

comment:6 @markjaquith7 years ago

+1 to setting the modified timestamp on the first save of the draft.

comment:7 in reply to: ↑ 5 @westi7 years ago

Replying to ryan:

Patch makes sure drafts have a modified time. That helps a bit.

in [6643]

comment:8 @ryan7 years ago

  • Milestone changed from 2.5 to 2.6

Might still be worth setting timestamps, but not for 2.5.

comment:9 @bryan8687 years ago

  • Milestone changed from 2.6 to 2.5

Can we at least in 2.5 get the drafts to display in reverse chronological order like they should? Like posts. Right now the oldest draft is at the top, and it's rather irritating. Refer here: http://trac.wordpress.org/ticket/5758

comment:10 @ryan7 years ago

Looks like mine do sort that way. Before [6643], however, drafts without modified time set would mess up the sort. If you have drafts without modified time, try re-saving and see if they sort properly.

comment:11 @lloydbudd7 years ago

Ryan, I can confirm for newere drafts, I see the desired behavior.

comment:12 @ryan7 years ago

  • Milestone changed from 2.5 to 2.6

comment:13 @redsweater7 years ago

  • Cc redsweater josephscott added

FYI this issue affects blog clients using the XMLRPC interface, as well. Because the dateless drafts show up at the very end chronologically, any client who asks for "getRecentPosts" will miss even a freshly added draft from the WP interface.

Would be a great improvement if new drafts get sorted correctly into the XMLRPC mix for "recent"...

Cc'ing josephscott so he can hopefully stay tuned and make sure that whatever fix gets made here also propagates to XMLRPC.

comment:14 @ryan6 years ago

Here's another method that sets post_date to the current time when a draft is saved but keeps post_date_gmt empty until the timestamp is explicitly edited. The empty post_date_gmt is used as the marker to indicate that post_date should be updated to the current time when saved.

@ryan6 years ago

comment:15 @ryan6 years ago

  • Milestone changed from 2.9 to 2.7

comment:16 @ryan6 years ago

(In [8920]) Set post_date for drafts. see #5698

comment:17 @ryan6 years ago

(In [8921]) Update post_date for old drafts during upgrade. see #5698

comment:18 @ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.