Fix a couple of deprecated warnings that appear in logs in newer php versions#535
Conversation
minncodebot
left a comment
There was a problem hiding this comment.
phpcs scanning turned up:
🚫 4 errors
hashes-api-scanning skipped
| @@ -1328,8 +1328,8 @@ public function get_failed_object_maps() { | |||
| $items_per_page = (int) get_option( $this->option_prefix . 'errors_per_page', 50 ); | |||
| $current_error_page = isset( $_GET['error_page'] ) ? (int) $_GET['error_page'] : 1; | |||
There was a problem hiding this comment.
| $offset = ( $current_error_page * $items_per_page ) - $items_per_page; | ||
| $all_errors = $this->wpdb->get_results( "SELECT * FROM ${table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT ${offset}, ${items_per_page}", ARRAY_A ); | ||
| $errors_total = $this->wpdb->get_var( "SELECT COUNT(`id`) FROM ${table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0" ); | ||
| $all_errors = $this->wpdb->get_results( "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}", ARRAY_A ); |
There was a problem hiding this comment.
🚫 Error: Use placeholders and $wpdb->prepare(); found interpolated variable $table at "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}" (WordPress.DB.PreparedSQL.InterpolatedNotPrepared).
| $offset = ( $current_error_page * $items_per_page ) - $items_per_page; | ||
| $all_errors = $this->wpdb->get_results( "SELECT * FROM ${table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT ${offset}, ${items_per_page}", ARRAY_A ); | ||
| $errors_total = $this->wpdb->get_var( "SELECT COUNT(`id`) FROM ${table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0" ); | ||
| $all_errors = $this->wpdb->get_results( "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}", ARRAY_A ); |
There was a problem hiding this comment.
🚫 Error: Use placeholders and $wpdb->prepare(); found interpolated variable $offset at "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}" (WordPress.DB.PreparedSQL.InterpolatedNotPrepared).
| $offset = ( $current_error_page * $items_per_page ) - $items_per_page; | ||
| $all_errors = $this->wpdb->get_results( "SELECT * FROM ${table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT ${offset}, ${items_per_page}", ARRAY_A ); | ||
| $errors_total = $this->wpdb->get_var( "SELECT COUNT(`id`) FROM ${table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0" ); | ||
| $all_errors = $this->wpdb->get_results( "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}", ARRAY_A ); |
There was a problem hiding this comment.
🚫 Error: Use placeholders and $wpdb->prepare(); found interpolated variable $items_per_page at "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}" (WordPress.DB.PreparedSQL.InterpolatedNotPrepared).
| $all_errors = $this->wpdb->get_results( "SELECT * FROM ${table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT ${offset}, ${items_per_page}", ARRAY_A ); | ||
| $errors_total = $this->wpdb->get_var( "SELECT COUNT(`id`) FROM ${table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0" ); | ||
| $all_errors = $this->wpdb->get_results( "SELECT * FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0 LIMIT {$offset}, {$items_per_page}", ARRAY_A ); | ||
| $errors_total = $this->wpdb->get_var( "SELECT COUNT(`id`) FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0" ); |
There was a problem hiding this comment.
🚫 Error: Use placeholders and $wpdb->prepare(); found interpolated variable $table at "SELECT COUNT(id) FROM {$table} WHERE salesforce_id LIKE 'tmp_sf_%' OR wordpress_id LIKE 'tmp_wp_%' OR last_sync_status = 0" (WordPress.DB.PreparedSQL.InterpolatedNotPrepared).
What does this Pull Request do?
In newer versions of PHP, the log entry
Using ${var} in strings is deprecatedappears. This fixes at least some of the places where this would happen.