Repository navigation
fix: suppress phpcs false-positives in database-check (closes #122) - #200
Merged
Merged
Conversation
…122) When this issue was filed, database-check.php had real SQL-injection exposure (unescaped \$where_clauses concatenated into the query). The file has since been refactored — all dynamic SQL now goes through \$wpdb->prepare() with %s placeholders, and the variables passed to prepare() are either literal pattern strings or \$wpdb->esc_like()'d constants. No user input ever touches the query string directly. What remained were three phpcs false-positives: 1. WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare (line 306) The WHERE clause is built from literal "option_value LIKE %s" fragments in a fixed-size loop. phpcs can't trace through implode + variadic spread to verify that the %s count matches ...\$values. 2. WordPress.DB.SlowDBQuery.slow_db_query_meta_key (line 515 SELECT) This is a security audit that intentionally scans usermeta for injected payloads. Slowness is the trade-off; LIMIT 50 + admin-only permission_callback keep blast radius small. Caching skipped on purpose — stale results would hide a fresh injection. 3. WordPress.DB.SlowDBQuery.slow_db_query_meta_key (line 531 array key) phpcs flags the PHP array key 'meta_key' as if it were a WP_Query argument. Same rule, false positive on a literal string key. Each suppression has a rationale comment explaining why. No behavior change — the SQL was already safe. Tests: 96 passing, unchanged. PHP lint: clean (0 errors, 0 warnings, was 0 errors / 2 warnings). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
5 tasks
ivdimova
approved these changes
May 12, 2026
ivdimova
left a comment
Collaborator
There was a problem hiding this comment.
Pure false-positive suppression with clear rationale comments. No logic changes. Safe to merge.
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.
Summary
Closes the SQL injection issue in `database-check.php` — but as a documentation/suppression PR rather than a behavior change. Net: +13 / -3 lines, 1 file touched.
Context
When #122 was filed, the file had real exposure: `$where_clauses` was concatenated unescaped into a query. The file has since been refactored — all dynamic SQL now goes through `$wpdb->prepare()` with `%s` placeholders, and the values passed are either literal pattern strings or `$wpdb->esc_like()`'d constants. No user input ever touches the query string directly.
What remained were 3 phpcs false-positives.
Suppressions added (with rationale comments)
What I did NOT change
The SQL itself. All three queries in this file already use `$wpdb->prepare()` with safe placeholder patterns. The phpcs warnings were noise, not findings.
Verification
What's still queued for v0.11
After this lands, the remaining WP.org blockers are:
Test plan
🤖 Generated with Claude Code