Skip to content

Plugin Check incorrectly reports %i placeholder as unsupported in WordPress 6.9 #1162

@LeninZapata

Description

@LeninZapata

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

  1. Create a custom database handler class using $wpdb->prepare() with %i placeholder
  2. Run Plugin Check on the code
  3. 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 %i placeholder has been available since WordPress 6.2
  • $wpdb->has_cap('identifier_placeholders') returns true

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:

  1. Using an incorrect version detection mechanism
  2. Testing against a minimum WordPress version declared in plugin headers rather than the actual installed version
  3. Not properly checking for identifier_placeholders capability

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions