Skip to content

Use prepared %i identifier placeholders in table strategies#36

Merged
alexstandiford merged 1 commit into
mainfrom
fix/identifier-placeholders
Jun 11, 2026
Merged

Use prepared %i identifier placeholders in table strategies#36
alexstandiford merged 1 commit into
mainfrom
fix/identifier-placeholders

Conversation

@alexstandiford

Copy link
Copy Markdown
Contributor

All table/column identifiers now go through $wpdb->prepare() with %i (WP 6.2+); INFORMATION_SCHEMA's TABLE_NAME comparison becomes a proper %s value placeholder, and the zero-arg prepare() 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.

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
@alexstandiford alexstandiford merged commit 6058c31 into main Jun 11, 2026
1 check passed
@alexstandiford alexstandiford deleted the fix/identifier-placeholders branch June 11, 2026 14:54
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.

Use %i identifier placeholder in WordPress query strategies instead of interpolation

1 participant