WordPress.org

Make WordPress Core

Changeset 45603


Ignore:
Timestamp:
07/05/2019 05:42:57 AM (5 months ago)
Author:
pento
Message:

Coding Standards: Fix all WordPress.DB.PreparedSQLPlaceholders issues.

See #47632.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-importer.php

    r45583 r45603  
    6565        // Get count of permalinks
    6666        $meta_key = $importer_name . '_' . $bid . '_permalink';
    67         $sql      = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = '%s'", $meta_key );
     67        $sql      = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key );
    6868
    6969        $result = $wpdb->get_results( $sql );
  • trunk/src/wp-admin/includes/export.php

    r45583 r45603  
    107107        $post_types = get_post_types( array( 'can_export' => true ) );
    108108        $esses      = array_fill( 0, count( $post_types ), '%s' );
    109         $where      = $wpdb->prepare( "{$wpdb->posts}.post_type IN (" . implode( ',', $esses ) . ')', $post_types );
     109
     110        // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
     111        $where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (" . implode( ',', $esses ) . ')', $post_types );
    110112    }
    111113
  • trunk/src/wp-includes/class-wp-comment-query.php

    r45590 r45603  
    772772            foreach ( $post_fields as $field_name => $field_value ) {
    773773                // $field_value may be an array.
    774                 $esses                                     = array_fill( 0, count( (array) $field_value ), '%s' );
     774                $esses = array_fill( 0, count( (array) $field_value ), '%s' );
     775
     776                // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
    775777                $this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value );
    776778            }
     
    793795                $join_posts_table = true;
    794796
    795                 $esses                                     = array_fill( 0, count( $q_values ), '%s' );
     797                $esses = array_fill( 0, count( $q_values ), '%s' );
     798
     799                // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
    796800                $this->sql_clauses['where'][ $field_name ] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $q_values );
    797801            }
  • trunk/src/wp-includes/class-wp-meta-query.php

    r45590 r45603  
    624624                case 'BETWEEN':
    625625                case 'NOT BETWEEN':
    626                     $meta_value = array_slice( $meta_value, 0, 2 );
    627                     $where      = $wpdb->prepare( '%s AND %s', $meta_value );
     626                    $where = $wpdb->prepare( '%s AND %s', $meta_value[0], $meta_value[1] );
    628627                    break;
    629628
  • trunk/src/wp-includes/taxonomy.php

    r45590 r45603  
    13771377        $where = 't.term_id = %d';
    13781378        if ( ! empty( $taxonomy ) ) {
     1379            // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
    13791380            return $wpdb->get_row( $wpdb->prepare( $tax_select . $where . ' AND tt.taxonomy = %s', $term, $taxonomy ), ARRAY_A );
    13801381        } else {
     
    14121413    }
    14131414
     1415    // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
    14141416    $result = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields ) );
    14151417    if ( $result ) {
     
    14171419    }
    14181420
     1421    // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
    14191422    return $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms as t WHERE $else_where $orderby $limit", $else_where_fields ) );
    14201423}
     
    37063709
    37073710        if ( $object_types ) {
     3711            // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.QuotedDynamicPlaceholderGeneration
    37083712            $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode( "', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );
    37093713        }
  • trunk/tests/phpunit/tests/db.php

    r44272 r45603  
    16131613        $part = $wpdb->prepare( ' AND meta_value = %s', ' %s ' );
    16141614        $this->assertNotContains( '%s', $part );
     1615        // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
    16151616        $query = $wpdb->prepare( 'SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s $part', array( 'foo', 'bar' ) );
    16161617        $this->assertNull( $query );
     
    16211622
    16221623        $actual = $wpdb->prepare(
     1624            // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder
    16231625            'WHERE second=%2$f AND first=%1$f',
    16241626            1.1,
     
    16351637
    16361638        $actual = $wpdb->prepare(
     1639            // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder
    16371640            'WHERE second=%2$f AND first=%1$f',
    16381641            array( 1.1, 2.2 )
Note: See TracChangeset for help on using the changeset viewer.