Skip to content

t534: fix(checkout): delay pending site fallback watchdog#1355

Merged
superdav42 merged 1 commit into
mainfrom
fix/1305-pending-site-watchdog
Jun 8, 2026
Merged

t534: fix(checkout): delay pending site fallback watchdog#1355
superdav42 merged 1 commit into
mainfrom
fix/1305-pending-site-watchdog

Conversation

@superdav42

@superdav42 superdav42 commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a delayed wu_async_publish_pending_site watchdog before loopback publish attempts so a started loopback still has a retry path if the long-running publish dies after the 2xx response
  • skip the immediate Action Scheduler fallback when a blocking loopback returns 2xx, avoiding the duplicate-publish race from t534: fix(membership): skip AS fallback enqueue when loopback publish returned 2xx (duplicate publish race) #1305
  • keep immediate fallback enqueue/dispatch for disabled, failed, or unknown loopback paths, and unschedule pending fallback work after a successful publish
  • add regression coverage for the delayed-watchdog branch and for loopback-disabled fallback enqueue

Resolves #1305

Verification

  • php -l inc/models/class-membership.php && php -l tests/WP_Ultimo/Managers/Membership_Manager_Test.php
  • vendor/bin/phpcs inc/models/class-membership.php tests/WP_Ultimo/Managers/Membership_Manager_Test.php
  • vendor/bin/phpstan analyse inc/models/class-membership.php --memory-limit=1G
  • git diff --check

Not run

  • Targeted vendor/bin/phpunit --filter ... Membership_Manager_Test.php — WordPress PHPUnit test suite is not installed in this environment.

aidevops.sh v3.20.36 plugin for OpenCode v1.16.2 with gpt-5.5

Summary by CodeRabbit

  • Bug Fixes
    • Improved pending site publication reliability by introducing a watchdog fallback mechanism that prevents duplicate publish attempts and handles edge cases where the initial publish process may not complete.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b2fa3d42-c492-4500-b875-42162617a16f

📥 Commits

Reviewing files that changed from the base of the PR and between 4c2fd3d and bc3a991.

📒 Files selected for processing (2)
  • inc/models/class-membership.php
  • tests/WP_Ultimo/Managers/Membership_Manager_Test.php

📝 Walkthrough

Walkthrough

This PR fixes a duplicate-publish race in the FPM pending-site publishing flow by introducing a delayed watchdog fallback and making async enqueue conditional on loopback failure. When loopback succeeds under FPM, the request completes early without enqueueing the redundant async action; a scheduled watchdog fallback provides safety if loopback never completed. Tests are updated for determinism and new watchdog behavior coverage.

Changes

Pending-Site Publish Watchdog and Async Fallback

Layer / File(s) Summary
Watchdog constant and deduplication helper
inc/models/class-membership.php
PENDING_SITE_PUBLISH_WATCHDOG_DELAY constant parameterizes the watchdog delay, and schedule_pending_site_async_watchdog() prevents duplicate delayed-action scheduling before enqueueing wu_async_publish_pending_site.
Loopback attempt and conditional async fallback
inc/models/class-membership.php
publish_pending_site_async() schedules a delayed watchdog upfront, returns early after successful loopback (2xx + early finish available), and enqueues the async fallback only when loopback did not succeed.
Completion cleanup
inc/models/class-membership.php
After successful pending-site publish, unschedules any previously scheduled wu_async_publish_pending_site action to prevent stale retries.
Test improvements and watchdog coverage
tests/WP_Ultimo/Managers/Membership_Manager_Test.php
Refactored existing tests to use named filter callbacks for deterministic cleanup, added a new test validating delayed watchdog scheduling after successful blocking loopback, and updated assertions to require async fallback enqueue only on loopback failure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

review-feedback-scanned, origin:worker

Poem

🐰 A watchdog now stands guard at the gate,
Where loopbacks race and publishes wait.
No more duplicate queues in the fray—
Early finish, then rest for the day! 🏃‍♂️✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title references fixing a duplicate publish race for pending site watchdog, which is the primary change.
Linked Issues check ✅ Passed All acceptance criteria from #1305 are met: conditional AS enqueue for loopback 2xx, preservation of fallback for failures, idempotency via locks, regression tests added.
Out of Scope Changes check ✅ Passed Changes are focused on pending site watchdog delay logic and related test improvements, all within scope of issue #1305.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1305-pending-site-watchdog

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42 superdav42 merged commit 20c8ed4 into main Jun 8, 2026
11 checks passed
@superdav42

Copy link
Copy Markdown
Collaborator Author

Summary

  • add a delayed wu_async_publish_pending_site watchdog before loopback publish attempts so a started loopback still has a retry path if the long-running publish dies after the 2xx response
  • skip the immediate Action Scheduler fallback when a blocking loopback returns 2xx, avoiding the duplicate-publish race from t534: fix(membership): skip AS fallback enqueue when loopback publish returned 2xx (duplicate publish race) #1305
  • keep immediate fallback enqueue/dispatch for disabled, failed, or unknown loopback paths, and unschedule pending fallback work after a successful publish
  • add regression coverage for the delayed-watchdog branch and for loopback-disabled fallback enqueue

Verification

  • php -l inc/models/class-membership.php && php -l tests/WP_Ultimo/Managers/Membership_Manager_Test.php
  • vendor/bin/phpcs inc/models/class-membership.php tests/WP_Ultimo/Managers/Membership_Manager_Test.php
  • vendor/bin/phpstan analyse inc/models/class-membership.php --memory-limit=1G
  • git diff --check

Not run

  • Targeted vendor/bin/phpunit --filter ... Membership_Manager_Test.php — WordPress PHPUnit test suite is not installed in this environment.

aidevops.sh v3.20.36 plugin for OpenCode v1.16.2 with gpt-5.5


Merged via PR #1355 to main.
Merged by deterministic merge pass (pulse-wrapper.sh).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-feedback-scanned Merged PR already scanned for quality feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t534: fix(membership): skip AS fallback enqueue when loopback publish returned 2xx (duplicate publish race)

1 participant