Problem
WordPress pseudo-cron can fire the same scheduled event multiple times if page loads overlap. Without a lock, the same import job can run concurrently, causing duplicate posts (TOCTOU race condition in duplicate detection) and wasted server resources.
Solution
import.php — In run_cron(), add a per-job transient lock:
- Before each job: check
get_transient('feedzy_import_lock_' . $job->ID), skip if active
- Set transient with 10-minute TTL before running the job
- Use
finally { delete_transient($lock_key); } to ensure cleanup on both success and error
- Log skipped jobs for debugging
Files Affected
includes/admin/feedzy-rss-feeds-import.php
Acceptance Criteria
Priority: High — prevents duplicate imported posts
Regression risk: Low — worst case a job is skipped once, retries on next cron cycle
Problem
WordPress pseudo-cron can fire the same scheduled event multiple times if page loads overlap. Without a lock, the same import job can run concurrently, causing duplicate posts (TOCTOU race condition in duplicate detection) and wasted server resources.
Solution
import.php — In
run_cron(), add a per-job transient lock:get_transient('feedzy_import_lock_' . $job->ID), skip if activefinally { delete_transient($lock_key); }to ensure cleanup on both success and errorFiles Affected
includes/admin/feedzy-rss-feeds-import.phpAcceptance Criteria
Priority: High — prevents duplicate imported posts
Regression risk: Low — worst case a job is skipped once, retries on next cron cycle