-
Notifications
You must be signed in to change notification settings - Fork 83
Description
Description
Plugin Check is reporting an error stating that the %i placeholder is "only supported in WP 6.2 or higher" even though I'm running WordPress 6.9.
Environment
- WordPress Version: 6.9
- Plugin Check Version: 1.8.0
- PHP Version: 8.1
Steps to Reproduce
- Create a custom database handler class using
$wpdb->prepare()with%iplaceholder - Run Plugin Check on the code
- Plugin Check reports:
WordPress.DB.PreparedSQLPlaceholders.UnsupportedIdentifierPlaceholder - The %i modifier is only supported in WP 6.2 or higher. Found: "%i".
Sample Code
global $wpdb;
$table_name = $wpdb->prefix . 'my_custom_table';
// This triggers the error even on WP 6.9
$results = $wpdb->get_results($wpdb->prepare(
"SELECT * FROM %i WHERE id = %d",
$table_name,
123
));Expected Behavior
Plugin Check should recognize that %i is supported since WordPress version is 6.9 (well above the 6.2 requirement).
Actual Behavior
Plugin Check throws an ERROR stating the placeholder is unsupported, even though:
- WordPress 6.9 is installed
- The
%iplaceholder has been available since WordPress 6.2 $wpdb->has_cap('identifier_placeholders')returnstrue
Additional Context
The %i placeholder was introduced in WordPress 6.2 (official announcement) specifically to address the PreparedSQL.InterpolatedNotPrepared warnings when working with custom database tables.
It appears Plugin Check may be:
- Using an incorrect version detection mechanism
- Testing against a minimum WordPress version declared in plugin headers rather than the actual installed version
- Not properly checking for
identifier_placeholderscapability
Workaround
Currently reverting to using interpolated table names with phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared comments, which generates warnings but is functionally correct.
Request
Could you please investigate why Plugin Check is not correctly detecting WordPress version or the availability of the %i placeholder? This is causing false positives that prevent developers from using the recommended modern approach for handling table names in prepared statements.