PluginProbe
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score / trunk
Powered Cache – Caching and Optimization for WordPress – Easily Improve PageSpeed & Web Vitals Score vtrunk
trunk 1.0 1.0.1 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1 2.1.1 2.1.2 2.2 2.2.1 All 69 releases
← All changes | includes/classes/Async/DatabaseOptimizer.php +9 -3 2.2trunk View file →
@@ -9,8 +9,12 @@
9 9
10 10 use const PoweredCache\Constants\DB_CLEANUP_COUNT_CACHE_KEY;
11 11 use \Powered_Cache_WP_Background_Process as Powered_Cache_WP_Background_Process;
12 12
13 +// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery
14 +// phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching
15 +
16 +
13 17 /**
14 18 * Class DatabaseOptimizer
15 19 */
16 20 class DatabaseOptimizer extends Powered_Cache_WP_Background_Process {
@@ -208,9 +212,11 @@
208 212 case 'db_cleanup_optimize_tables':
209 213 $query = $wpdb->get_results( $wpdb->prepare( "SELECT table_name, data_free FROM information_schema.tables WHERE table_schema = %s and Engine <> 'InnoDB' and data_free > 0", DB_NAME ) );
210 214 if ( $query ) {
211 215 foreach ( $query as $table ) {
212 - $wpdb->query( "OPTIMIZE TABLE $table->table_name" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
216 + if ( ! empty( $table->table_name ) ) {
217 + $wpdb->query( 'OPTIMIZE TABLE `' . esc_sql( $table->table_name ) . '`' ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
218 + }
213 219 }
214 220 }
215 221 break;
216 222 }
@@ -219,9 +225,9 @@
219 225 }
220 226
221 227 /**
222 228 * Sometimes canceling a process is glitchy
223 - * Try to cancell all items in the queue up to $max_attempt
229 + * Try to cancel all items in the queue up to $max_attempt
224 230 */
225 231 public function cancel_process() {
226 232 $max_attempt = 5;
227 233 $cancelled = 0;
@@ -228,9 +234,9 @@
228 234 while ( ! parent::is_queue_empty() ) {
229 235 if ( $cancelled >= $max_attempt ) {
230 236 break;
231 237 }
232 - parent::cancel_process();
238 + parent::cancel();
233 239 $cancelled ++;
234 240 }
235 241 }
236 242