Make WordPress Core

Opened 3 weeks ago

Last modified 8 days ago

#63360 new defect (bug)

ignore_sticky_posts generating a wrong behaviour in WP_Query

Reported by: sirlouen's profile SirLouen Owned by:
Milestone: Awaiting Review Priority: normal
Severity: blocker Version: 6.8
Component: Query Keywords: needs-patch has-test-info
Focuses: Cc:

Description

Bug Report

Description

According to the docs:

ignore_sticky_posts (boolean) – ignore post stickiness (available since version 3.1, replaced caller_get_posts parameter). false (default): move sticky posts to the start of the set. true: do not move sticky posts to the start of the set.


Something is going wrong with ignore_sticky_posts behavior when certain WP_Query args are being used (the __in ones more specifically).

More importantly, since, ignore_sticky_posts is false by default, it can be easily reproduced as soon as we use any of these arguments for the query.

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.5
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 135.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.2
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Steps to Reproduce

  1. Install this simple plugin for testing: https://raw.githubusercontent.com/SirLouen/wp-query-tester/refs/tags/1.0.1/wp-query-tester.php
  2. Create a second username
  3. Create some posts in this order:
  • First post, make sticky
  • Second not sticky post. Call it exactly, "Not Sticky 1", with slug "not-sticky-1".
  • Third, make sticky post
  • Fourth not sticky post
  • Fifth a sticky post, with second username as author
  • Sixth, not sticky with second username as author
  1. Create another post and add the short code [wp_query_tester]
  2. 🐞 Bug occurs

Expected Results

  • Query 1: All posts with sticky on top
  • Query 2: All posts ignoring the stickyness
  • Query 3: All posts from Author 1
  • Query 4: The post with slug "not-sticky"

Actual Results

  1. Query 1 is ✅
  • Query 2 is ✅
  • Query 3 is ❌. Queried only author 1. A post from author 2 appears (because its sticky)
  • Query 4 is ❌. Queried just the slug not-sticky-1. All sticky posts appear, the last one is the one queried.

Additional Notes

This topic is seriously correlated with this issue #63307 just as a reference.

Supplemental Artifacts

Plugin repo: https://github.com/SirLouen/wp-query-tester/

Screenshot Sample

https://i.imgur.com/ILiKfgs.png

Change History (2)

This ticket was mentioned in Slack in #core-test by sirlouen. View the logs.


3 weeks ago

#3 @wordpressdotorg
8 days ago

  • Keywords has-test-info added; has-testing-info removed
Note: See TracTickets for help on using tickets.