Skip to content

Commit 50bb23e

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@60094 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b943118 commit 50bb23e

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/wp-admin/includes/class-wp-importer.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ public function get_imported_posts( $importer_name, $blog_id ) {
2929
// Grab all posts in chunks.
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.
3642
$offset = ( $limit + $offset );
@@ -62,9 +68,12 @@ public function count_imported_posts( $importer_name, $blog_id ) {
6268

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 ) ) {
7079
$count = (int) $result[0]->cnt;
@@ -91,8 +100,13 @@ public function get_imported_comments( $blog_id ) {
91100

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.
98112
$offset = ( $limit + $offset );

0 commit comments

Comments
 (0)