Make WordPress Core

Opened 4 weeks ago

Last modified 10 days ago

#63359 new defect (bug)

Are ignore_sticky_posts working as expected?

Reported by: sirlouen's profile SirLouen Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version:
Component: Query Keywords: needs-patch has-test-info 2nd-opinion
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 feels to be going wrong with ignore_sticky_posts behaviour.

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/heads/main/wp-query-tester.php
  2. Create some posts in this order:
  • First 1 sticky post
  • Second 1 not sticky post
  • Third 1 sticky post
  • Fourth 1 not sticky post
  1. Run the plugin in the menu
  2. 🐞 Bug occurs

Expected Results

  1. ✅ According to the docs, sticky should go first

Actual Results

  1. ❌ Sticky results and the same as regular results.

Additional Notes

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

Supplemental Artifacts

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

Change History (7)

#1 follow-up: @karthikeya01
4 weeks ago

Yes, I can reproduce it. I noticed that this only happens in the admin area — the sticky posts are not displayed at the top there. When I try the same WP_Query on frontend pages, the sticky posts appear at the top as expected.
This might be the intended behavior:
https://github.com/WordPress/wordpress-develop/blob/839c81706ebb2e29c4f70436eb62cec16602d0a7/src/wp-includes/class-wp-query.php#L3563

Last edited 4 weeks ago by karthikeya01 (previous) (diff)

#2 in reply to: ↑ 1 @SirLouen
4 weeks ago

  • Keywords 2nd-opinion added

Replying to karthikeya01:

Yes, I can reproduce it. I noticed that this only happens in the admin area — the sticky posts are not displayed at the top there. When I try the same WP_Query on frontend pages, the sticky posts appear at the top as expected.
This might be the intended behavior:
https://github.com/WordPress/wordpress-develop/blob/839c81706ebb2e29c4f70436eb62cec16602d0a7/src/wp-includes/class-wp-query.php#L3563

Very nice spot! Now I can truly reproduce the bug I was willing to reproduce originally, I might close this report, and open a new one to provide the full information and avoid confusions.

Still, I'm not 100% confident that this behavior is ideal (admin-level not being able to reproduce the listings to my requirements). I think that the admin hindrance should be removed.

So I will be leaving this open this for further opinions on this topic.

Last edited 4 weeks ago by SirLouen (previous) (diff)

#3 @SirLouen
4 weeks ago

PS: If anyone can edit the plugin link (@sabernhardt)
https://raw.githubusercontent.com/SirLouen/wp-query-tester/refs/heads/main/wp-query-tester.php

With this new one:
https://raw.githubusercontent.com/SirLouen/wp-query-tester/refs/tags/1.0.0/wp-query-tester.php

And also I would change the title to
"Stickiness wrong behaviour in Admin pages"

To reflect the new status.

Last edited 4 weeks ago by SirLouen (previous) (diff)

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


3 weeks ago

#7 @SirLouen
3 weeks ago

@sabernhardt I think it looked the same, but here there are two reports in one.

  1. One report is related to an admin-level minor priority trouble: why the condition is ignoring sticky in the wp-admin pages.
  1. The second one, with maximum priority, is the one you merged here wrongly, is about a broken WP Query that is affecting a couple of other issues.

They looked very similar because one helped me find the other (in fact I was looking for the second, but I found this in between). But both must be addressed (specially the second, with the highest priority, it must be punted to 6.8.2)

Can you revert changes and leave them as they were before?

#8 @sabernhardt
3 weeks ago

(reverted ticket changes)

#9 @wordpressdotorg
10 days ago

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