Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#11966 closed defect (bug) (fixed)

Sticky posts not removed from query results when pushed to front of posts

Reported by: jeffstieler Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 2.9.1
Component: General Keywords: has-patch tested
Focuses: Cc:


array_search() is being used to determine the offset of a processed sticky post in the query results, and array_splice() is being used to remove it from the queue.

array_search() returns the key for the sticky post, and array_splice() expects a numerical index

If the key returned by array_search() does not match the sticky post's actual offset in the array, it is not removed and appears as a duplicate.

Attachments (1)

query.php.diff (434 bytes) - added by jeffstieler 8 years ago.

Download all attachments as: .zip

Change History (3)

#1 @prettyboymp
8 years ago

  • Keywords tested added
  • Milestone changed from Unassigned to 3.0
  • Version set to 2.9.1


To test, add a filter to 'option_sticky_posts' that returns the array with keys set, ie; apply something like array_diff() to the sticky_posts array.

#2 @nacin
8 years ago

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

(In [14135]) Fix sticky post handling. Use unset instead of array_splice to remove an item by key retrieved by array_search. props jeffstieler, fixes #11966.

Note: See TracTickets for help on using tickets.