WordPress.org

Make WordPress Core

#25127 closed defect (bug) (fixed)

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

Reported by: druesome Owned by: 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 21 months ago.
ignore auto-draft posts in sticky count

Download all attachments as: .zip

Change History (8)

comment:1 @SergeyBiryukov21 months ago

  • Component changed from General to Administration

Related: #17115, #23623, #23887.

comment:2 @helen21 months 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.

comment:3 @helen21 months ago

  • Component changed from General to Administration

comment:4 @westi21 months 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.

comment:5 @nofearinc21 months 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.

@nofearinc21 months ago

ignore auto-draft posts in sticky count

comment:6 @nacin19 months ago

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

comment:7 @nacin19 months 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.