Make WordPress Core

Changeset 54858


Ignore:
Timestamp:
11/19/2022 03:40:11 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Fix WPCS issues in wp-admin/install-helper.php.

This commit adds inline comments instructing PHPCS to ignore some lines for database queries. An explanation is provided with each instruction.

This resolves a few WPCS warnings along the lines of:

Use placeholders and $wpdb->prepare(); found interpolated variable $table_name at "DESC $table_name"

Follow-up to [236], [265], [5778].

Props jipmoors, costdev, jrf, SergeyBiryukov.
Fixes #43761.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/install-helper.php

    r53232 r54858  
    6060
    6161        // Didn't find it, so try to create it.
     62        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query.
    6263        $wpdb->query( $create_ddl );
    6364
     
    8990        global $wpdb;
    9091
     92        // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names.
    9193        foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    9294            if ( $column === $column_name ) {
     
    9698
    9799        // Didn't find it, so try to create it.
     100        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query.
    98101        $wpdb->query( $create_ddl );
    99102
    100103        // We cannot directly tell that whether this succeeded!
     104        // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names.
    101105        foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    102106            if ( $column === $column_name ) {
     
    124128    global $wpdb;
    125129
     130    // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names.
    126131    foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    127132        if ( $column === $column_name ) {
    128133
    129134            // Found it, so try to drop it.
     135            // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query.
    130136            $wpdb->query( $drop_ddl );
    131137
    132138            // We cannot directly tell that whether this succeeded!
     139            // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names.
    133140            foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    134141                if ( $column === $column_name ) {
     
    175182    global $wpdb;
    176183
    177     $diffs   = 0;
     184    $diffs = 0;
     185
     186    // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names.
    178187    $results = $wpdb->get_results( "DESC $table_name" );
    179188
Note: See TracChangeset for help on using the changeset viewer.