Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#27734 closed defect (bug) (fixed)

3.8.2 Regression: quick post on dashboard no-longer functioning

Reported by: kirrus's profile kirrus Owned by: nacin's profile nacin
Milestone: 3.8.3 Priority: normal
Severity: normal Version: 3.8.2
Component: Posts, Post Types Keywords: has-patch
Focuses: administration Cc:

Description

The quickpost dashboard widget no-longer functions in wordpress 3.8.2. This happens on both new and upgraded installs.

Debug mode/error logs are showing it throwing the following error:
Notice: Undefined index: post_status in /path/to/docuroot/wp-admin/includes/post.php on line 206

This appears to be affecting updated users badly:
https://wordpress.org/support/topic/quick-draft-doesnt-save-the-posts-all-lost

Attachments (3)

27734.diff (989 bytes) - added by dd32 11 years ago.
Convert auto-draft to draft AFTER _wp_translate_post_data() has set the post status..
27734.2.diff (1.7 KB) - added by nacin 11 years ago.
27734.3.diff (2.0 KB) - added by nacin 11 years ago.

Download all attachments as: .zip

Change History (21)

#1 @kpdesign
11 years ago

I can confirm this issue in 3.8.2, no plugins, running Twenty Twelve theme - get the same error message.

I checked the database, and the auto-draft of the post is there, but it is not displaying as a draft on the Posts page (post_date_gmt is all zeros - 0000-00-00 00:00:00).

If I try to enter a new post using quick draft, the existing auto-draft (post title and content) in the database is being overwritten, rather than a second draft being created.

@dd32
11 years ago

Convert auto-draft to draft AFTER _wp_translate_post_data() has set the post status..

#2 @SergeyBiryukov
11 years ago

  • Keywords has-patch added
  • Version set to 3.8.2

Introduced in [27976].

Trunk is not affected, as the line that causes the notice was removed in [26995].

Last edited 11 years ago by SergeyBiryukov (previous) (diff)

#3 @SergeyBiryukov
11 years ago

#27748 was marked as a duplicate.

#4 @nacin
11 years ago

  • Milestone changed from Awaiting Review to 3.8.3

#5 @nacin
11 years ago

In 28073:

Ensure edit_post() promotes an auto-draft to draft. Fixes Quick Draft.

For the 3.8 branch. Regression from [27976] that does not affect trunk.

props dd32.
see #27734.

#6 @nacin
11 years ago

In 28074:

Ensure edit_post() promotes an auto-draft to draft. Fixes Quick Draft.

Merges [28073] from the 3.8 branch to the 3.7 branch.

props dd32.
see #27734.

@nacin
11 years ago

@nacin
11 years ago

#7 @nacin
11 years ago

27734.2.diff attempts to rescue lost auto drafts. 27734.3.diff takes it further by making sure we also try to rescue title-only Quick Drafts (those submitted without content). I recognize both patches incorrectly refer to 3.8.2, not 3.8.3.

This patch can't do a raw query against usermeta for dashboard_quick_press_last_post_id as these are per-site options, so they'd be keyed by the DB prefix. Thus we need to look into the posts table for items that fit our criteria. It ends up being pretty simple: post_type of 'post', post_status of 'auto-draft', post_date after 3.7.2/3.8.2 shipped. This query uses the type_status_date index so it's fast. auto-drafts are garbage collected every 7 days so there isn't much for it to find.

It then goes through each auto-draft. If it has content, it knows it needs to be promoted. If it only has a title, then we need to check that it is not 'Auto Draft' (as in, a regular auto draft either in use or waiting to be GC'd). A note, it's not feasible for an auto-draft to have neither a title nor content, as then wp_insert_post() will reject it as being empty.

Why am I saying "try" or "attempt" to rescue? Unfortunately, each save of Quick Draft by the same user would update the existing auto draft they previously lost. If they used Quick Draft in succession, or tried again when they couldn't find their post — both of which are not unlikely — we can only rescue their last edit. This is because Quick Draft holds onto a single auto-draft post ID per user and will re-use it as long as it remains an auto draft. (This was for performance — it prevents new auto drafts from being created every time the dashboard was visited.)

Ironically, when Quick Press became Quick Draft in 3.8 and was greatly simplified, we no longer had a need for auto drafts as we were no longer supporting media. We should have dropped this convoluted logic entirely and that's something we can now do in 4.0.

#8 @nacin
11 years ago

I also meant to explain that this avoids wp_update_post() for two reasons:

  • It's not easy to avoid having the post_date updated to the time of the upgrade routine. We want these to come back in situ.
  • It seems like we should not fire any hooks for these.

This ticket was mentioned in IRC in #wordpress-dev by nacin. View the logs.


11 years ago

#10 @dd32
11 years ago

I've tested both 27734.2.diff and 27734.3.diff and both work as I'd expect.

Testing was done by installing 3.8.1, Creating quick drafts, monitoring the DB, and then running upgrade_382() from the command line. post_title only, post_content only, post_title and post_content all tested out OK, further drafts created after this didn't overwrite the drafts either (As expected).

#11 follow-up: @miqrogroove
11 years ago

Why db_version 30000?

#12 in reply to: ↑ 11 @nacin
11 years ago

Replying to miqrogroove:

Why db_version 30000?

Just a placeholder until things are committed.

#13 @SergeyBiryukov
11 years ago

Both 27734.2.diff and 27734.3.diff work as expected for me.

Noticed #27760 and #27761 while testing this.

#14 @nacin
11 years ago

Note that there was a typo in the second patch, $post_id instead of $post->ID for cleaning the cache.

When doing a DB bump, we normally bump to the latest SVN version. We are not doing that here as it is in a branch. In the past we have only done +1, and I'm doing that here as well.

#15 @nacin
11 years ago

In 28075:

Recover auto-drafts lost via Quick Draft.

For the 3.8 branch. See [28074].

see #27734.

#16 @nacin
11 years ago

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

In 28077:

Recover auto-drafts lost via Quick Draft.

Merges [28075] from the 3.8 to the 3.7 branch. See [28074].

fixes #27734.

#17 @SergeyBiryukov
11 years ago

#27769 was marked as a duplicate.

#18 @nacin
11 years ago

#27795 was marked as a duplicate.

Note: See TracTickets for help on using tickets.