Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#25127 closed defect (bug) (fixed)

Saving an empty draft sticky post leads to auto-drafts being marked as sticky

Reported by: druesome's profile druesome Owned by: nacin's profile nacin
Milestone: 3.7 Priority: normal
Severity: normal Version: 3.6
Component: Administration Keywords: has-patch
Focuses: Cc:

Description (last modified by westi)

If you save an empty post set as sticky as draft it increments number of Sticky Posts because the auto-draft's ID ends up in the list of sticky posts:

To reproduce error:

  1. Create New Post, leave everything empty
  2. Tick 'Stick this post to the front page'
  3. Click Save as Draft

Reproduced in a clean install of WordPress v3.6, default theme with no plugins activated.

http://i.imgur.com/bXZzm5F.jpg

Attachments (1)

25127.patch (860 bytes) - added by nofearinc 11 years ago.
ignore auto-draft posts in sticky count

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
11 years ago

  • Component changed from General to Administration

Related: #17115, #23623, #23887.

#2 @helen
11 years ago

  • Component changed from Administration to General
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Also related: #11082

Closing as a dupe of #17115.

#3 @helen
11 years ago

  • Component changed from General to Administration

#4 @westi
11 years ago

  • Description modified (diff)
  • Keywords needs-patch added
  • Milestone set to 3.7
  • Resolution duplicate deleted
  • Status changed from closed to reopened
  • Summary changed from Missing Empty Posts to Saving an empty draft sticky post leads to auto-drafts being marked as sticky

Re-opening and focusing on the specific different issue from the other tickets and a specific issue which can easily be solved independently.

#5 @nofearinc
11 years ago

  • Cc mario@… added
  • Keywords has-patch added; needs-patch removed

The problem is that wp_insert_post breaks earlier when an empty post has been found and assigned as true to the $maybe_empty variable. Initially, a post has a status of auto-draft which isn't updated to draft unless there is any valid data in the title or content.

IMO this makes sense and also happens when you skip step 2 (i.e. just hit 'Save Draft' for an empty post).

My proposal is just counting the sticky posts properly by ignoring auto-draft posts as well.

@nofearinc
11 years ago

ignore auto-draft posts in sticky count

#6 @nacin
11 years ago

Committing this; but otherwise it would be nice to fix #17115.

#7 @nacin
11 years ago

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

In 25678:

Avoid counting auto-drafts in sticky.

props nofearinc.
fixes #25127.

Note: See TracTickets for help on using tickets.