Use prepared %i identifier placeholders in table strategies#36
Merged
Conversation
Replace string-interpolated table/column identifiers with $wpdb->prepare() and the %i identifier placeholder (WP 6.2+) across QueryStrategy::estimatedCount, the empty-row INSERT in CanQueryWordPressDatabase, TableDeleteStrategy's DROP TABLE, and TableCreate/TableUpdateStrategy's DDL. Also fixes two real misuses in TableUpdateStrategy::getCurrentColumns: TABLE_NAME was interpolated into value position (now a %s placeholder) and prepare() was called with zero arguments, which triggers _doing_it_wrong on every column sync. Identifiers all resolve from internal Table objects today, so this is hardening plus correct wpdb usage rather than a live injection fix. Requires WordPress 6.2+ for %i. Fixes #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All table/column identifiers now go through
$wpdb->prepare()with%i(WP 6.2+); INFORMATION_SCHEMA's TABLE_NAME comparison becomes a proper%svalue placeholder, and the zero-argprepare()misuse (fires_doing_it_wrong) is gone. Package suite green (59 tests). Fixes #33.Surfaced by Siren's WordPress.org review simulation — direct sibling of a real round-4 review finding.