From 60f368054e30f098976bef9be035f569a8fb554c Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Wed, 28 Feb 2024 15:44:50 +0200 Subject: [PATCH] fix: prevent jobs from stopping the cron loop --- includes/admin/feedzy-rss-feeds-import.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index 8d63c40b..cbb5d579 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -1187,13 +1187,20 @@ public function run_cron( $max = 100 ) { 'post_status' => 'publish', 'numberposts' => 99, ); + $feedzy_imports = get_posts( $args ); foreach ( $feedzy_imports as $job ) { - $result = $this->run_job( $job, $max ); - if ( empty( $result ) ) { - $this->run_job( $job, $max ); + try { + $result = $this->run_job( $job, $max ); + if ( empty( $result ) ) { + $this->run_job( $job, $max ); + } + do_action( 'feedzy_run_cron_extra', $job ); + } catch ( Exception $e ) { + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { + error_log( '[Feedzy Run Cron][Post title: ' . ( ! empty( $job->post_title ) ? $job->post_title : '' ) . '] Error: ' . $e->getMessage() ); + } } - do_action( 'feedzy_run_cron_extra', $job ); } }