WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 3 weeks ago

#52007 new defect (bug)

sticky_posts somehow ends up with duplicate IDs and unstickying only removes one at a time

Reported by: archon810 Owned by:
Milestone: 5.7 Priority: normal
Severity: normal Version: 5.5.3
Component: Posts, Post Types Keywords: needs-patch
Focuses: Cc:

Description

Hi all,

Somehow we ran into this bug on production where the sticky_posts array ended up with duplicate IDs that were stickied, and unstickying only removed the same ID one at a time instead of all of them at once, so unstickying kept the post stickied until it was unstickied enough times to clear the array.

For example, this is how I found sticky_posts:

a:3:{i:1;i:744381;i:2;i:725382;i:3;i:725382;}

Note that 725382 is duplicated. Unstickying once did this:

a:2:{i:0;i:744381;i:1;i:725382;}

How we got to the duplicate ID state, I cannot say (perhaps that's a separate bug), but solution here is to not exit the loop when the ID is reached and removed and instead keep going till the end.

Change History (1)

#1 @SergeyBiryukov
3 weeks ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 5.7

Thanks for the ticket! It seems like we should run array_unique() on the sticky_posts option at some point here.

Note: See TracTickets for help on using tickets.