Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent jobs from stopping the cron loop #897

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading