Repository navigation
wpdb: Escape column identifiers in CRUD methods - #15802
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. 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. |
Trac ticket: https://core.trac.wordpress.org/ticket/60505
wpdb::insert(),replace(),update()anddelete()accept raw column names, but interpolate them between backticks before preparing the query. A valid name containing a backtick breaks the SQL, and a name containing%scan be mistaken for a value placeholder.Pass column names as
%iarguments instead. INSERT/REPLACE place the identifier arguments before the value arguments; UPDATE and DELETE keep each identifier beside its optional value. NULL assignments andIS NULLconditions still omit the value argument. Empty INSERT/REPLACE data continues to returnfalserather than becoming a default-row insert.This addresses column identifiers across the CRUD methods. It does not change table-name interpolation or introduce new identifier-validity rules. Related PR #9292 changes validation inside
prepare(); it does not update these CRUD call sites. The linked public ticket records that the security team reviewed the report and requested a public ticket.Testing
Use a temporary table with a valid column named
back`tickorpercent%s, then insert, replace, update and delete through the public CRUD methods. The operations should round-trip their values without SQL errors. The regression tests create and remove their own temporary tables and also cover NULL data/conditions, string/integer/float formats, ordinary column names and zero affected rows.Tests_DBclass passes in single-site and multisite: 531 tests each.Use of AI Tools
AI assistance: Yes
Tool(s): Codex
Used for: Investigating the ticket and related PRs, implementation, regression tests, validation, and independent automated code review. This contribution has not received a human review from the account owner.
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.