Skip to content

Commit

Permalink
Fix queries to find options
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevalk committed Sep 6, 2024
1 parent 69e4936 commit 9a420c1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions aaa-option-optimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ function aaa_option_optimizer_activation() {
$placeholders = implode( ',', array_fill( 0, count( $autoload_values ), '%s' ) );
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-time query, no caching needed.
$result = $wpdb->get_row(
$wpdb->prepare(
"SELECT COUNT(*) AS count, SUM(LENGTH(option_value)) AS autoload_size FROM {$wpdb->options} WHERE autoload IN ( %s )",
$placeholders
)
$wpdb->prepare( "SELECT count(*) AS count, SUM( LENGTH( option_value ) ) as autoload_size FROM {$wpdb->options} WHERE autoload IN ( $placeholders )", $autoload_values )

Check failure on line 40 in aaa-option-optimizer.php

View workflow job for this annotation

GitHub Actions / Check code style

Use placeholders and $wpdb->prepare(); found interpolated variable $placeholders at "SELECT count(*) AS count, SUM( LENGTH( option_value ) ) as autoload_size FROM {$wpdb->options} WHERE autoload IN ( $placeholders )"

Check warning on line 40 in aaa-option-optimizer.php

View workflow job for this annotation

GitHub Actions / Check code style

Replacement variables found, but no valid placeholders found in the query.
);
update_option(
'option_optimizer',
Expand Down
2 changes: 1 addition & 1 deletion src/class-admin-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function ( $value, $key ) {
$placeholders = implode( ',', array_fill( 0, count( $autoload_values ), '%s' ) );
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery
$result = $wpdb->get_row(
$wpdb->prepare( "SELECT count(*) AS count, SUM( LENGTH( option_value ) ) as autoload_size FROM {$wpdb->options} WHERE autoload IN ( %s )", $placeholders )
$wpdb->prepare( "SELECT count(*) AS count, SUM( LENGTH( option_value ) ) as autoload_size FROM {$wpdb->options} WHERE autoload IN ( $placeholders )", $autoload_values )

Check failure on line 290 in src/class-admin-page.php

View workflow job for this annotation

GitHub Actions / Check code style

Use placeholders and $wpdb->prepare(); found interpolated variable $placeholders at "SELECT count(*) AS count, SUM( LENGTH( option_value ) ) as autoload_size FROM {$wpdb->options} WHERE autoload IN ( $placeholders )"

Check warning on line 290 in src/class-admin-page.php

View workflow job for this annotation

GitHub Actions / Check code style

Replacement variables found, but no valid placeholders found in the query.
);

echo '<h2>' . esc_html__( 'Stats', 'aaa-option-optimizer' ) . '</h2>';
Expand Down

0 comments on commit 9a420c1

Please sign in to comment.