Skip to content

Tests: Use the recognized ID orderby value in a query test (7.1) - #13969

Open
lancewillett wants to merge 1 commit into
WordPress:7.1from
lancewillett:backport/65893-thepost-orderby-7.1
Open

lancewillett wants to merge 1 commit into
WordPress:7.1from
lancewillett:backport/65893-thepost-orderby-7.1

Conversation

@lancewillett

@lancewillett lancewillett commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Trac ticket: https://core.trac.wordpress.org/ticket/65893

Tests_Query_ThePost::test_wp_query_with_custom_fields_value_populates_the_global_post passes 'orderby' => 'id'. WP_Query does not recognize id (the allowed key is ID), so the query falls back to ordering by date. The four fixture pages share a date, so the database chooses the order. On MariaDB the test can return a different child page than it expects, depending on the post IDs that earlier tests in the run leave behind. Trunk fixed this in 64016; the 7.1, 7.0, 6.9 and 6.8 branches still have the old value.

Backports the thePost.php change from [64016] to the 7.1 branch.

Only the orderby value changes; the other changes in [64016] are not included.

Related branches: 7.0: #13968, 6.9: #13970, 6.8: #13971.

Validation

The identical one-line change passed npm run test:php -- --filter Tests_Query_ThePost on 7.0: 16 tests, 61 assertions.

Use of AI Tools

AI assistance: Yes
Tool(s): Codex
Model(s): gpt-6
Used for: Applying the existing fix, preparing the commits and PR descriptions, and running local validation.

`Tests_Query_ThePost::test_wp_query_with_custom_fields_value_populates_the_global_post()` ordered its query by `id`, which `WP_Query` does not recognize. The query fell back to ordering by date, and the fixture pages share a date, so the result depended on the database's tie order.

Backports the `thePost.php` change from [64016] to the 7.1 branch.

Props jonsurrell, adrianmoldovanwp.
See #65893.
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props lancewillett.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@lancewillett
lancewillett requested a review from a team October 3, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant