Skip to content

Commit

Permalink
Merge pull request #897 from Codeinwp/fix/feeds-import-cron
Browse files Browse the repository at this point in the history
fix: prevent jobs from stopping the cron loop
  • Loading branch information
Soare-Robert-Daniel authored Mar 21, 2024
2 parents d042b65 + 553e74d commit e6773d0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

Expand Down Expand Up @@ -1775,7 +1782,7 @@ function( $term ) {
}

// Fetch image from graby.
if ( empty( $image_url ) && ( wp_doing_cron() || defined( 'FEEDZY_PRO_FETCH_ITEM_IMG_URL' ) ) ) {
if ( empty( $image_url ) && ( wp_doing_cron() && defined( 'FEEDZY_PRO_FETCH_ITEM_IMG_URL' ) ) ) {
// if license does not exist, use the site url
// this should obviously never happen unless on dev instances.
$license = apply_filters( 'product_feedzy_license_key', sprintf( 'n/a - %s', get_site_url() ) );
Expand Down

0 comments on commit e6773d0

Please sign in to comment.