Make WordPress Core

Changeset 60094


Ignore:
Timestamp:
03/25/2025 06:34:48 PM (18 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Remove a one-time $sql variable in WP_Importer methods.

This allows the $wpdb::prepare() calls to be picked up correctly by PHPCS.

Follow-up to [14760].

Props aristath, poena, afercia, SergeyBiryukov.
See #63168.

File:
1 edited

Legend:

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

    r59754 r60094  
    3030                do {
    3131                        $meta_key = $importer_name . '_' . $blog_id . '_permalink';
    32                         $sql      = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d", $meta_key, $offset, $limit );
    33                         $results  = $wpdb->get_results( $sql );
     32                        $results  = $wpdb->get_results(
     33                                $wpdb->prepare(
     34                                        "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d",
     35                                        $meta_key,
     36                                        $offset,
     37                                        $limit
     38                                )
     39                        );
    3440
    3541                        // Increment offset.
     
    6369                // Get count of permalinks.
    6470                $meta_key = $importer_name . '_' . $blog_id . '_permalink';
    65                 $sql      = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key );
    66 
    67                 $result = $wpdb->get_results( $sql );
     71                $result   = $wpdb->get_results(
     72                        $wpdb->prepare(
     73                                "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s",
     74                                $meta_key
     75                        )
     76                );
    6877
    6978                if ( ! empty( $result ) ) {
     
    92101                // Grab all comments in chunks.
    93102                do {
    94                         $sql     = $wpdb->prepare( "SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d", $offset, $limit );
    95                         $results = $wpdb->get_results( $sql );
     103                        $results = $wpdb->get_results(
     104                                $wpdb->prepare(
     105                                        "SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d",
     106                                        $offset,
     107                                        $limit
     108                                )
     109                        );
    96110
    97111                        // Increment offset.
Note: See TracChangeset for help on using the changeset viewer.