Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#12859 closed defect (bug) (fixed)

Preview new, blank page/post creates broken preview

Reported by: duck_'s profile duck_ Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: General Keywords: has-patch needs-testing
Focuses: Cc:



  1. Add new post or page, don't add any content
  2. 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.

Attachments (2)

preview-blank.diff (1.2 KB) - added by duck_ 14 years ago.
12859.diff (496 bytes) - added by duck_ 14 years ago.

Download all attachments as: .zip

Change History (6)

14 years ago

#1 @duck_
14 years ago

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.

#2 @duck_
14 years ago

Related: #11082

Previous ticket (didn't notice it) about trying to save empty draft.

14 years ago

#3 @duck_
14 years ago

Refreshed patch with better behaviour when previewing post/page with content but no title (for example)

#4 @ryan
14 years ago

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

(In [14643]) Don't allow previewing auto-draft. Props duck_. fixes #12859

Note: See TracTickets for help on using tickets.