#27734 closed defect (bug) (fixed)
3.8.2 Regression: quick post on dashboard no-longer functioning
Reported by: |
|
Owned by: |
|
---|---|---|---|
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)
Change History (21)
@
11 years ago
Convert auto-draft to draft AFTER _wp_translate_post_data() has set the post status..
#2
@
11 years ago
- Keywords has-patch added
- Version set to 3.8.2
#7
@
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
@
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
@
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).
#13
@
11 years ago
Both 27734.2.diff and 27734.3.diff work as expected for me.
#14
@
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.
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.