From add2390cb6ddcc00641a9b699a12e21e31b71c3c Mon Sep 17 00:00:00 2001 From: Nicolas Lemoine Date: Wed, 30 Oct 2024 13:09:43 +0100 Subject: [PATCH] Fix object cache insanity when `--filter-keep` is enabled --- inc/class-revisions-cli.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/inc/class-revisions-cli.php b/inc/class-revisions-cli.php index dc611d6..d068807 100644 --- a/inc/class-revisions-cli.php +++ b/inc/class-revisions-cli.php @@ -320,7 +320,7 @@ public function clean( $args = array(), $assoc_args = array() ) { $total_deleted = 0; $this->start_bulk_operation(); - + $inc = 0; foreach ( $posts as $post_id ) { // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_children @@ -343,6 +343,10 @@ public function clean( $args = array(), $assoc_args = array() ) { if ( isset( $assoc_args['filter-keep'] ) ) { $keep = wp_revisions_to_keep( get_post( $post_id ) ); + $inc++; + if ( $inc % 10 === 0 ) { + $this->stop_the_insanity(); + } } $count = count( $revisions );