Preview new, blank page/post creates broken preview
|Reported by:||duck_||Owned by:|
- Add new post or page, don't add any content
- Click "Preview"
Redirected to preview page with large number of errors.
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.