Skip to content

Fix a couple of deprecated warnings that appear in logs in newer php versions#535

Merged
jonathanstegall merged 1 commit intomasterfrom
remove-some-deprecations
May 18, 2024
Merged

Fix a couple of deprecated warnings that appear in logs in newer php versions#535
jonathanstegall merged 1 commit intomasterfrom
remove-some-deprecations

Conversation

@jonathanstegall
Copy link
Copy Markdown
Member

What does this Pull Request do?

In newer versions of PHP, the log entry Using ${var} in strings is deprecated appears. This fixes at least some of the places where this would happen.

@jonathanstegall jonathanstegall added the chore Pull request that does maintenance tasks label May 18, 2024
@jonathanstegall jonathanstegall added this to the v2.2.9 milestone May 18, 2024
Copy link
Copy Markdown

@minncodebot minncodebot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs scanning turned up:

🚫 4 errors

⚠️ 1 warning


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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Warning: Processing form data without nonce verification (WordPress.Security.NonceVerification.Recommended).

$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 );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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 );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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" );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 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).

@jonathanstegall jonathanstegall merged commit d04d776 into master May 18, 2024
@jonathanstegall jonathanstegall deleted the remove-some-deprecations branch May 18, 2024 20:02
@jonathanstegall jonathanstegall added the patch pull request that requires a patch release, ex v2.1.2. This is the default for new releases. label May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Pull request that does maintenance tasks patch pull request that requires a patch release, ex v2.1.2. This is the default for new releases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants