Repository navigation
Query Loop: Normalize invalid sticky post options - #14617
salvatorecorsi wants to merge 1 commit into
Conversation
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Query Loop can throw a PHP
TypeErrorwhen its sticky-post setting isexcludeand the storedsticky_postsoption is a string or is missing. A nonempty string also reachespost__inunchanged inonlymode.Normalize a non-array option to an empty local list before constructing the query. Valid arrays retain their existing behavior;
onlystill uses the existingarray( 0 )sentinel to return no posts. The stored option is not modified. This follows the defensive handling already used by other sticky-post readers.Trac ticket: https://core.trac.wordpress.org/ticket/60276
To reproduce on a disposable test site, set
sticky_poststo an empty string, insert a Query Loop with inherited query disabled, select Sticky Posts → Exclude, and render or save the template. Before this change,array_merge()receives a string; afterwards the query runs without treating the invalid value as post IDs. The ticket's original corrupted value was observed on an old WordPress.com site; its source was not established.Validation on Windows, PHP 8.3.28, PHPUnit 9.6.38, using the isolated native test database:
WP_Block/WP_Querycases covering three sticky modes, empty/nonempty/numeric strings, a missing option and an empty-array control. They also verify explicit exclusions and that the option is not rewritten. Against unchanged runtime: 4TypeErrors and 2 assertion failures (15 tests, 29 assertions); with the fix: 15 tests, 45 assertions passed.scripts/test-php.ps1 -Repository wordpress-develop -Checkout C:/Users/salva/.wp-fix/worktrees/wordpress-develop-60276 -Filter '^Tests_Blocks_wpBlock::': 64 tests, 221 assertions passed, including the existing valid-array sticky-post cases.git diff --check: passed.npm run buildafter the runtime fix: passed. The built and sourcewp-includes/blocks.phpcopies have identical SHA-256 hashes. Existing Node deprecation and webpack asset-size/performance warnings remain nonfatal.A preliminary broader filter (
Tests_Blocks_wpBlock) also matched unrelated metadata-registry classes: 241 tests / 531 assertions with one Windows path-separator failure. That exact registry test fails identically against the frozen unchanged runtime (1 test / 2 assertions). It is retained as a known baseline limitation. PHPUnit also reports its existing deprecated XML-schema warning. No full PHPUnit, multisite or Docker E2E pass is claimed.Use of AI Tools
AI assistance: Yes. OpenAI Codex investigated the ticket, authored the implementation and regression tests, and ran the recorded automated validation. A separate Codex agent reviewed the source, tests and results. The owner has not performed a human review; maintainer review is needed for acceptance into WordPress.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.