Repository navigation
Conversation
…rch terms. When all search terms are exclusions (e.g. `?s=-foo&orderby=relevance`), `search_orderby_title` is empty, but missing parentheses in the condition made `orderby=relevance` call `parse_search_order()` anyway. This produced `ORDER BY DESC` or `CASE WHEN THEN 2` and a database error. See #50871.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
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. |
When all search terms are exclusions (e.g.
?s=-foo&orderby=relevance),search_orderby_titleis empty, but missing parentheses in the condition inWP_Query::get_posts()letorderby=relevancecallparse_search_order()anyway, producing
ORDER BY DESC/CASE WHEN THEN 2and a DB error.This adds the parentheses so the relevance clause is only built when there
are title terms. Same fix as proposed by leedxw in Trac comment:6.
Trac ticket: https://core.trac.wordpress.org/ticket/50871
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code, with code-intruder (my own static analysis tool)
Model(s): Claude Opus, Claude Haiku
Used for: The issue was surfaced by code-intruder (call-graph regression +
AI review of the flagged sinks). AI helped confirm the root cause, check that
it cannot be escalated to SQL injection, and verify the fix on a clean 7.1.4
install. I reviewed and tested the one-line change myself.
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.