[wp-trac] [WordPress Trac] #56091: Using %i for table/field names in wpdb::prepare()

WordPress Trac noreply at wordpress.org
Thu Jul 27 14:37:01 UTC 2023


#56091: Using %i for table/field names in wpdb::prepare()
-----------------------------+---------------------------
 Reporter:  craigfrancis     |       Owner:  craigfrancis
     Type:  enhancement      |      Status:  assigned
 Priority:  low              |   Milestone:  6.4
Component:  Database         |     Version:  6.1
 Severity:  minor            |  Resolution:
 Keywords:  has-patch early  |     Focuses:
-----------------------------+---------------------------

Comment (by SergeyBiryukov):

 This came up in a coding session with @afercia, @aristath, and @poena,
 where we tried to address the existing WPCS warnings for missing or
 incorrect usage of `$wpdb->prepare()` in core, so I'm moving this to 6.4
 for review.

 We have also noticed that the `%i` placeholder is not currently recognized
 by WPCS, as seen on the PR:
 {{{
 Unsupported placeholder used in $wpdb->prepare(). Found: "%i".
 }}}

 This [https://github.com/WordPress/WordPress-Coding-Standards/pull/2072
 appears to be fixed] in an upcoming version of WPCS.

 In our testing, this silences the error for now, until WPCS is updated in
 core:
 {{{
 // The placeholder ignores can be removed when %i is supported by WPCS.
 // phpcs:ignore
 WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder,
 WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56091#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list