From f299e3c83a584bbf180b1c377773795950fbfac1 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 19 Nov 2022 15:42:16 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@54858 git-svn-id: http://core.svn.wordpress.org/trunk@54410 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/install-helper.php | 11 ++++++++++- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/wp-admin/install-helper.php b/wp-admin/install-helper.php index 733321c13e..e07b3d8edd 100644 --- a/wp-admin/install-helper.php +++ b/wp-admin/install-helper.php @@ -59,6 +59,7 @@ if ( ! function_exists( 'maybe_create_table' ) ) : } // Didn't find it, so try to create it. + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query. $wpdb->query( $create_ddl ); // We cannot directly tell that whether this succeeded! @@ -88,6 +89,7 @@ if ( ! function_exists( 'maybe_add_column' ) ) : function maybe_add_column( $table_name, $column_name, $create_ddl ) { global $wpdb; + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { if ( $column === $column_name ) { return true; @@ -95,9 +97,11 @@ if ( ! function_exists( 'maybe_add_column' ) ) : } // Didn't find it, so try to create it. + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query. $wpdb->query( $create_ddl ); // We cannot directly tell that whether this succeeded! + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { if ( $column === $column_name ) { return true; @@ -123,13 +127,16 @@ endif; function maybe_drop_column( $table_name, $column_name, $drop_ddl ) { global $wpdb; + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { if ( $column === $column_name ) { // Found it, so try to drop it. + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- No applicable variables for this query. $wpdb->query( $drop_ddl ); // We cannot directly tell that whether this succeeded! + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) { if ( $column === $column_name ) { return false; @@ -174,7 +181,9 @@ function maybe_drop_column( $table_name, $column_name, $drop_ddl ) { function check_column( $table_name, $col_name, $col_type, $is_null = null, $key = null, $default_value = null, $extra = null ) { global $wpdb; - $diffs = 0; + $diffs = 0; + + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Cannot be prepared. Fetches columns for table names. $results = $wpdb->get_results( "DESC $table_name" ); foreach ( $results as $row ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index c1589842ae..1cc063d75a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-54857'; +$wp_version = '6.2-alpha-54858'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.