PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.4.2
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.4.2
1.4.2 1.4.1 1.4.0 1.3.7 1.3.6 1.3.5 1.3.4 1.3.3 1.3.2 1.3.1 1.3.0 1.2.4 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 36 releases
← All changes | includes/modules/Database/DatabaseModule.php +23 -3 1.4.0 → 1.4.2 View file →
@@ -201,8 +201,15 @@
201 201 public function deactivate(): void {
202 202 wp_clear_scheduled_hook( Database_Cleaner::CRON_HOOK );
203 203 }
204 204
205 + /**
206 + * The schedule or the selected types changed: reschedule, and drop the
207 + * scheduled clean's resume point. A cursor left in place would carry on
208 + * deleting a category the user has just switched off. Any other save
209 + * returns early and keeps both. clean() also discards a cursor written for
210 + * a different selection, so this is the belt to that brace.
211 + */
205 212 public function on_settings_change( $old, $new ): void {
206 213 // A revision-limit save must not reschedule cleanup: apply_schedule()
207 214 // restarts the timer, which pulled a weekly run forward on every save.
208 215 $old = is_array( $old ) ? $old : array();
@@ -212,8 +219,9 @@
212 219 return;
213 220 }
214 221 $schedule = is_array( $new ) ? (string) ( $new['schedule'] ?? 'manual' ) : 'manual';
215 222 $types = is_array( $new ) && isset( $new['included_types'] ) && is_array( $new['included_types'] ) ? $new['included_types'] : array();
223 + Database_Cleaner::reset_cursor();
216 224 Database_Cleaner::apply_schedule( $schedule, $types );
217 225 }
218 226
219 227 public function on_settings_added( $name, $value ): void {
@@ -218,8 +226,9 @@
218 226
219 227 public function on_settings_added( $name, $value ): void {
220 228 $schedule = is_array( $value ) ? (string) ( $value['schedule'] ?? 'manual' ) : 'manual';
221 229 $types = is_array( $value ) && isset( $value['included_types'] ) && is_array( $value['included_types'] ) ? $value['included_types'] : array();
230 + Database_Cleaner::reset_cursor();
222 231 Database_Cleaner::apply_schedule( $schedule, $types );
223 232 }
224 233
225 234 public function rest_scan( \WP_REST_Request $request ) {
@@ -256,9 +265,9 @@
256 265
257 266 switch ( $action ) {
258 267 case 'scan':
259 268 foreach ( Database_Cleaner::scan() as $key => $row ) {
260 - \WP_CLI::log( sprintf( '%-22s %s — %d rows', $key, $row['label'], $row['count'] ) );
269 + \WP_CLI::log( sprintf( '%-26s %s — %d rows', $key, $row['label'], $row['count'] ) );
261 270 }
262 271 return;
263 272
264 273 case 'clean':
@@ -263,10 +272,21 @@
263 272
264 273 case 'clean':
265 274 $types = isset( $assoc['types'] ) ? array_filter( array_map( 'trim', explode( ',', (string) $assoc['types'] ) ) ) : array_keys( Database_Cleaner::type_labels() );
266 275 $res = Database_Cleaner::clean( $types );
267 - foreach ( $res['cleaned'] as $key => $affected ) {
268 - \WP_CLI::log( sprintf( '%-22s %d removed', $key, $affected ) );
276 + foreach ( $res['skipped'] as $key ) {
277 + \WP_CLI::warning( sprintf( 'Unknown type "%s" skipped. Run `wp xspeed db scan` for the list.', $key ) );
278 + }
279 + foreach ( $res['remaining'] as $key => $left ) {
280 + \WP_CLI::log( sprintf( '%-26s %d removed, %d left', $key, (int) ( $res['cleaned'][ $key ] ?? 0 ), $left ) );
281 + }
282 + $left = array_sum( $res['remaining'] );
283 + if ( $res['partial'] && $left > 0 ) {
284 + // Each run is time-boxed so a large trash can't outlive the
285 + // request. Nothing carries over: the next run starts over
286 + // on whatever still matches.
287 + \WP_CLI::warning( sprintf( 'Stopped at the time limit. %d left — run it again to continue.', $left ) );
288 + return;
269 289 }
270 290 \WP_CLI::success( 'Cleanup complete.' );
271 291 return;
272 292