Skip to content

fix(checkout): dispatch pending site async on FrankenPHP#1353

Merged
superdav42 merged 1 commit into
mainfrom
fix/frankenphp-pending-site-async
Jun 6, 2026
Merged

fix(checkout): dispatch pending site async on FrankenPHP#1353
superdav42 merged 1 commit into
mainfrom
fix/frankenphp-pending-site-async

Conversation

@superdav42

@superdav42 superdav42 commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • skip the pending-site loopback fast path unless the runtime exposes litespeed_finish_request() or fastcgi_finish_request()
  • immediately dispatch the Action Scheduler async runner when the loopback is skipped or fails
  • keep a response-finish helper for LiteSpeed/FastCGI/manual flushing and add regression coverage for fallback behavior

Verification

  • php -l inc/models/class-membership.php && php -l inc/managers/class-membership-manager.php && php -l tests/WP_Ultimo/Managers/Membership_Manager_Test.php
  • git diff --check
  • vendor/bin/phpunit --filter 'test_publish_pending_site_async_generates_token|test_publish_pending_site_async_can_skip_loopback_via_filter|test_publish_pending_site_async_enqueues_fallback_on_http_errors' — OK (3 tests, 7 assertions)
  • dev checkout-path runtime checks: 5 async site-creation attempts returned in under 5s and left pending_with_site=0, unfinished_publish_actions=0

Notes

  • FrankenPHP v1.4.4/PHP 8.4.5 testing showed no exposed frankenphp_finish_request() function, so this avoids relying on it.
  • Broader vendor/bin/phpunit --filter 'Membership_Manager_Test|Membership_Test' currently has unrelated fixture reuse failures (User id ... has been used) in async transfer/delete tests.

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

Summary by CodeRabbit

  • Bug Fixes

    • Improved pending site publication reliability with asynchronous processing and automatic fallback mechanisms.
    • Enhanced HTTP response handling to ensure proper client communication during site provisioning.
  • Tests

    • Updated test coverage for pending site publication fallback behavior and HTTP error handling.

@coderabbitai

coderabbitai Bot commented Jun 6, 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: 81c65d32-193e-49aa-9c49-c8460701361e

📥 Commits

Reviewing files that changed from the base of the PR and between 70e3c57 and 7569c55.

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

📝 Walkthrough

Walkthrough

This PR refactors pending site publishing to separate HTTP response handling from async provisioning logic. The Manager now sends and finishes HTTP responses early via reusable helpers before enqueuing async work. The Membership model conditionally uses loopback based on server capabilities and falls back to immediate Action Scheduler dispatch when loopback fails or cannot be used, eliminating duplicate enqueuing.

Changes

Pending Site Publish Response and Loopback Fallback

Layer / File(s) Summary
Manager response handling refactoring
inc/managers/class-membership-manager.php
publish_pending_site() delegates the "creating-site" JSON response to send_pending_site_publish_started_response(), which sets Content-Length and appropriate headers, then calls finish_pending_site_publish_response() to complete the response. The finish helper prefers litespeed_finish_request() or fastcgi_finish_request() and otherwise flushes buffers so loopback clients can receive the response before provisioning continues.
Membership async loopback and fallback dispatch
inc/models/class-membership.php
publish_pending_site_async() guards the loopback fast-path by checking for server capability via litespeed_finish_request/fastcgi_finish_request and a new wu_publish_pending_site_can_finish_request filter. It tracks loopback startup only on 2xx HTTP responses. When loopback does not start, dispatch_pending_site_async_queue() immediately instantiates and runs ActionScheduler_AsyncRequest_QueueRunner for fallback processing, ensuring the async action executes without relying solely on background loopback.
Test updates for loopback conditioning and fallback
tests/WP_Ultimo/Managers/Membership_Manager_Test.php
HMAC token generation test temporarily enables the wu_publish_pending_site_can_finish_request filter before testing. Loopback-disable test now captures URLs only when the request contains wu_publish_pending_site. HTTP error handling test is renamed to test_publish_pending_site_async_enqueues_fallback_on_http_errors() and reworked to assert Action Scheduler fallback job queueing on HTTP 400, removing prior log file assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

  • Ultimate-Multisite/ultimate-multisite#792: Both PRs modify the pending-site publish workflow to enqueue/dispatch wu_async_publish_pending_site for a given membership—main PR refactors the HTTP/loopback+enqueue path in publish_pending_site*, while retrieved PR re-enqueues the same async action after resetting a stale is_publishing state in the AJAX status handler.

  • Ultimate-Multisite/ultimate-multisite#372: Both PRs touch the pending-site async publish flow in inc/managers/class-membership-manager.php: the main PR refactors publish_pending_site() to early-send/finish the response and enqueue async_publish_pending_site(), while the retrieved PR changes async_publish_pending_site() to conditionally call set_time_limit(0).

Suggested labels

bug, origin:worker

Poem

🐰 The site now starts with haste and grace,
Response sent to every place.
Loopback runs or quick retreats,
Action Scheduler safely meets—
No duplicates shall spoil the feast! 🎉

🚥 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 The title 'fix(checkout): dispatch pending site async on FrankenPHP' clearly describes the main change: enabling pending site async dispatch for FrankenPHP and other runtimes without LiteSpeed/FastCGI helpers.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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/frankenphp-pending-site-async

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 6, 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 2496f7e into main Jun 6, 2026
11 checks passed
@superdav42

Copy link
Copy Markdown
Collaborator Author

Summary

  • skip the pending-site loopback fast path unless the runtime exposes litespeed_finish_request() or fastcgi_finish_request()
  • immediately dispatch the Action Scheduler async runner when the loopback is skipped or fails
  • keep a response-finish helper for LiteSpeed/FastCGI/manual flushing and add regression coverage for fallback behavior

Verification

  • php -l inc/models/class-membership.php && php -l inc/managers/class-membership-manager.php && php -l tests/WP_Ultimo/Managers/Membership_Manager_Test.php
  • git diff --check
  • vendor/bin/phpunit --filter 'test_publish_pending_site_async_generates_token|test_publish_pending_site_async_can_skip_loopback_via_filter|test_publish_pending_site_async_enqueues_fallback_on_http_errors' — OK (3 tests, 7 assertions)
  • dev checkout-path runtime checks: 5 async site-creation attempts returned in under 5s and left pending_with_site=0, unfinished_publish_actions=0

Notes

  • FrankenPHP v1.4.4/PHP 8.4.5 testing showed no exposed frankenphp_finish_request() function, so this avoids relying on it.
  • Broader vendor/bin/phpunit --filter 'Membership_Manager_Test|Membership_Test' currently has unrelated fixture reuse failures (User id ... has been used) in async transfer/delete tests.

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


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

@superdav42 superdav42 added the review-feedback-scanned Merged PR already scanned for quality feedback label Jun 7, 2026
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.

1 participant