mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@54858 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
868709a4e7
commit
cfd09a4127
@ -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 ) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user