Skip to content

Commit

Permalink
Fix more CS
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevalk committed Sep 6, 2024
1 parent 14fa0e6 commit 6b6a493
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
5 changes: 4 additions & 1 deletion aaa-option-optimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ function aaa_option_optimizer_activation() {
global $wpdb;
$autoload_values = \wp_autoload_values_to_autoload();
$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.

// phpcs:disable WordPress.DB
$result = $wpdb->get_row(
$wpdb->prepare( "SELECT count(*) AS count, SUM( LENGTH( option_value ) ) as autoload_size FROM {$wpdb->options} WHERE autoload IN ( $placeholders )", $autoload_values )
);
// phpcs:enable WordPress.DB

update_option(
'option_optimizer',
[
Expand Down
34 changes: 17 additions & 17 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/class-admin-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,12 @@ function ( $value, $key ) {
global $wpdb;
$autoload_values = \wp_autoload_values_to_autoload();
$placeholders = implode( ',', array_fill( 0, count( $autoload_values ), '%s' ) );
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery

// phpcs:disable WordPress.DB
$result = $wpdb->get_row(
$wpdb->prepare( "SELECT count(*) AS count, SUM( LENGTH( option_value ) ) as autoload_size FROM {$wpdb->options} WHERE autoload IN ( $placeholders )", $autoload_values )
);
// phpcs:enable WordPress.DB

echo '<h2>' . esc_html__( 'Stats', 'aaa-option-optimizer' ) . '</h2>';
echo '<p>' .
Expand Down
2 changes: 1 addition & 1 deletion src/class-rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function update_option_autoload( $request ) {
$option_name = $request['option_name'];
$autoload = $request['autoload'];
$option_value = get_option( $option_name );

if ( ! in_array( $autoload, [ 'yes', 'on', 'no', 'off','auto', 'auto-on', 'auto-off' ], true ) ) {
return new \WP_Error( 'invalid_autoload_value', 'Invalid autoload value', [ 'status' => 400 ] );
}
Expand Down

0 comments on commit 6b6a493

Please sign in to comment.