Skip to content

Conversation

@GaryJones
Copy link
Contributor

Summary

  • Adds validation checks before scheduling auto-retry cron jobs after pull failures
  • Prevents indefinite requeuing of invalid jobs that can never complete successfully
  • Refactors to use early returns for cleaner code flow

Problem

When a pull failure occurred, the auto-retry handler would schedule a cron job without validating the site data. This caused problems when:

  1. The syn_site post no longer exists (get_post() returns null, causing fatal errors)
  2. The post exists but is the wrong post type
  3. The site has no valid syndication URL configured

These conditions would cause the cron job to keep requeuing indefinitely whilst never being able to complete successfully.

Solution

Added three validation checks to handle_pull_failure_event():

  1. Post existence check: Verify the post exists and is a WP_Post instance
  2. Post type check: Verify the post type is syn_site
  3. URL validation: Verify the feed URL is valid using filter_var()

Also:

  • Refactored to use early returns for cleaner code flow
  • Changed date() to gmdate() to address PHPCS timezone warnings

Test plan

  • All 91 unit tests pass
  • New tests cover all validation scenarios (21 tests added)
  • PHP syntax validated

Fixes #101

🤖 Generated with Claude Code

Previously, when a pull failure occurred, the auto-retry handler would
schedule a cron job without validating the site data. This could cause
problems when:

1. The syn_site post no longer exists (get_post returns null)
2. The post exists but is the wrong post type
3. The site has no valid syndication URL configured

These conditions would cause the cron job to keep requeuing indefinitely
whilst never being able to complete successfully.

The fix adds three validation checks:
- Verify the post exists and is a WP_Post instance
- Verify the post type is syn_site
- Verify the feed URL is a valid URL using filter_var

Also refactored to use early returns for cleaner code flow and changed
date() to gmdate() to address PHPCS timezone warnings.

Fixes #101

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@GaryJones GaryJones requested a review from a team as a code owner January 4, 2026 10:13
@GaryJones GaryJones self-assigned this Jan 4, 2026
@GaryJones GaryJones added the type: bug Something isn't working label Jan 4, 2026
@GaryJones GaryJones added this to the 2.2.0 milestone Jan 4, 2026
@GaryJones GaryJones merged commit 06cc119 into develop Jan 4, 2026
8 checks passed
@GaryJones GaryJones deleted the fix/101-cron-validation-after-pull-failure branch January 4, 2026 10:40
@GaryJones GaryJones mentioned this pull request Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More validation before queuing a cron job after pull failure

2 participants