Opened 15 years ago
Closed 15 years ago
#12859 closed defect (bug) (fixed)
Preview new, blank page/post creates broken preview
Reported by: | duck_ | Owned by: | |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | General | Keywords: | has-patch needs-testing |
Focuses: | Cc: |
Description
Steps:
- Add new post or page, don't add any content
- Click "Preview"
Actual:
Redirected to preview page with large number of errors.
Expected:
WordPress execution killed with message 'Preview not available. Please save as a draft first.' (2.9.2 behaviour)
I believe this is occurring because all new pages and posts are now created with a postID (see r12987). Therefore the check for $post_ID < 1 in post_preview() (wp-admin/includes/post.php, line 1288) is rendered ineffective.
Instead of checking the post_ID variable I think the function should check for status being auto_draft. However, if this is done, after autosaving a title a new post will still generate this error when previewing (create new post, type a title, let it autosave, click preview). This is because in wp-admin/js/autosave.js (autosave_update_post_ID function) checks value of #post_ID field against the newly autosaved ID, if they're equal the function terminates and so #auto_draft field is not set to '0'. I think the check was there to stop unnecessary ajax requests, but the function no longer does this... removing this also has benefit of reenabling the publishing buttons quicker than default 5000ms.
Similarly, clicking save draft or move to trash (not sure if you should be even able to do that on a completely new post, I know it used to be hidden) yields unexpected behaviour. Unsure whether they should have separate tickets or be grouped as the underlying problem is the fact that all new posts have an ID straight away.