Skip to content

t793: fix duplicate AS enqueue in stale-flag reset path#795

Closed
superdav42 wants to merge 0 commit intomainfrom
bugfix/793-remove-duplicate-retry-enqueue
Closed

t793: fix duplicate AS enqueue in stale-flag reset path#795
superdav42 wants to merge 0 commit intomainfrom
bugfix/793-remove-duplicate-retry-enqueue

Conversation

@superdav42
Copy link
Copy Markdown
Collaborator

Summary

Removes a duplicate Action Scheduler enqueue from check_pending_site_created() that created two competing retry sources when a stale is_publishing flag was detected.

Problem

In Membership_Manager::check_pending_site_created(), when is_publishing_stale() returns true, the code was:

  1. Resetting the stale flag
  2. Enqueuing a new wu_async_publish_pending_site AS action
  3. Returning publish_status => 'stopped' to the frontend

This created two competing retry paths:

  • Frontend: On stopped, polls 3 more times (9s), then reloads the page which kicks wp-cron.php → triggers AS
  • Action Scheduler: The explicitly enqueued job runs independently

Both paths call publish_pending_site() and can race, potentially attempting site creation twice simultaneously.

Fix

Remove the wu_enqueue_async_action call. The frontend stopped response already handles retry adequately — after 3 consecutive stopped responses, it reloads the page which kicks cron, and the AS job will retry on the next cron run without an explicit enqueue.

Files Modified

  • EDIT: inc/managers/class-membership-manager.php:221-225 — remove wu_enqueue_async_action call, update comment

Runtime Testing

Risk level: Low — this is a deletion of a redundant code path. The remaining retry mechanism (frontend polling + cron) was already present and functional before PR #792 added the enqueue.

Self-assessed: The change removes one of two competing retry sources. The surviving path (frontend stopped → reload → cron kick) is the same mechanism that worked before the stale-flag detection was added.

Resolves #793


aidevops.sh v3.6.238 plugin for OpenCode v1.3.16 with claude-sonnet-4-6 spent 2m and 4,672 tokens on this as a headless worker.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 11, 2026

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 22 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 21 minutes and 22 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e5764cb5-388d-4a0c-97a4-f8a39f1e1ca5

📥 Commits

Reviewing files that changed from the base of the PR and between 3d73e0f and 71d7701.

📒 Files selected for processing (1)
  • inc/managers/class-membership-manager.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/793-remove-duplicate-retry-enqueue

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
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

@github-actions
Copy link
Copy Markdown

Performance Test Results

Performance test results for 07afb3d are in 🛎️!

Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown.

URL: /

Run DB Queries Memory Before Template Template WP Total LCP TTFB LCP - TTFB
0 41 37.78 MB 874.50 ms (+41.50 ms / +5% ) 166.50 ms 1077.00 ms (+28.00 ms / +3% ) 2036.00 ms 1946.65 ms 91.75 ms
1 56 49.02 MB 950.00 ms 145.50 ms 1097.00 ms 2070.00 ms 1989.60 ms 82.00 ms

@superdav42
Copy link
Copy Markdown
Collaborator Author

Merge Summary

Status: Ready to merge — all CI checks pass, awaiting required human review approval.

What was done: Removed the wu_enqueue_async_action call from the stale is_publishing flag reset path in Membership_Manager::check_pending_site_created(). This eliminates two competing retry sources (frontend polling + explicit AS enqueue) that could race and attempt site creation twice simultaneously.

Files changed: inc/managers/class-membership-manager.php — 1 line removed, comment updated.

CI results: All 10 checks pass (PHP Lint, PHP 8.2/8.3/8.4/8.5, Code Quality, Build Plugin, WP Performance Metrics, Cypress 8.1/8.2, CodeRabbit).

Testing: Self-assessed (low risk — pure deletion of a redundant code path). The surviving retry mechanism (frontend stopped → 3 polls → page reload → cron kick) was already present and functional before PR #792 added the explicit enqueue.

Merge command (once approved):

gh pr merge 795 --squash --repo Ultimate-Multisite/ultimate-multisite

aidevops.sh v3.6.239 plugin for OpenCode v1.3.16 with claude-sonnet-4-6 spent 30m and 3,288 tokens on this as a headless worker. Overall, 28m since this issue was created.

@superdav42 superdav42 closed this Apr 11, 2026
@superdav42 superdav42 force-pushed the bugfix/793-remove-duplicate-retry-enqueue branch from 71d7701 to d0a653a Compare April 11, 2026 05:35
@superdav42
Copy link
Copy Markdown
Collaborator Author

Closing as superseded by PR #797.

PR #797 (already merged) implements the identical fix — removing the wu_enqueue_async_action call from the stale is_publishing reset path in check_pending_site_created(). Both PRs address the same dual retry path issue from issue #793.

The change in this PR is already in main via commit 34c09161.


aidevops.sh v3.6.239 plugin for OpenCode v1.3.16 with claude-sonnet-4-6 spent 8m and 11,355 tokens on this as a headless worker. Overall, 1h 3m since this issue was created.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quality-debt: PR #792 review feedback (medium)

1 participant