wordpress-develop icon indicating copy to clipboard operation
wordpress-develop copied to clipboard

WP_Query: force deterministic ordering

Open ramonjd opened this issue 3 months ago • 6 comments

I'm testing out an approach to fix a long-standing issue:

https://core.trac.wordpress.org/ticket/47642 https://core.trac.wordpress.org/ticket/52907 https://core.trac.wordpress.org/ticket/64042 https://core.trac.wordpress.org/ticket/44349 https://core.trac.wordpress.org/ticket/46294 https://core.trac.wordpress.org/ticket/8107 (17 years! 🏅 )

Possibly related too:

https://core.trac.wordpress.org/ticket/46294 https://core.trac.wordpress.org/ticket/52626

Unit tests to come once I've validated the approach.

This change addresses potential duplicate records across pages when multiple posts share the same value for a field.

It updates WP_Query ordering to ensure deterministic results by adding ID as a secondary sort field.

npm run test:php -- --filter Tests_Query_DeterministicOrdering

ramonjd avatar Oct 15 '25 02:10 ramonjd