fix: recover interrupted pending site polling#1415
Conversation
📝 WalkthroughWalkthroughThis PR adds a recovery mechanism for pending site creation when the underlying blog is created but publish cleanup is interrupted. The backend adds a ChangesPending Site Recovery and Polling
Sequence DiagramsequenceDiagram
participant PollHandler as check_pending_site_created()
participant Recovery as recover_interrupted_pending_site()
participant DB as Database/Site Meta
participant Hook as wu_pending_site_published
PollHandler->>Recovery: Attempt recovery of interrupted publish
activate Recovery
Recovery->>DB: Fetch existing blog by domain/path
Recovery->>DB: Validate membership/customer meta match
alt Blog exists and meta valid
Recovery->>DB: Copy signup options into blog context
Recovery->>DB: Update site meta (membership, customer, type)
Recovery->>DB: Delete pending site record
Recovery->>DB: Unschedule delayed publish action
Recovery->>Hook: Fire wu_pending_site_published event
Recovery-->>PollHandler: return true (success)
else Blog missing or meta mismatch
Recovery-->>PollHandler: return false (continue normal flow)
end
deactivate Recovery
PollHandler->>PollHandler: Return publish_status = completed if recovered
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
🔨 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! Login credentials: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
inc/managers/class-membership-manager.php (1)
382-391: 💤 Low valueUse Yoda conditions for the
!==comparisons.The coding guidelines require Yoda conditions in production code. The comparisons on lines 385 and 389 should have the literal/method result on the left side.
Proposed fix
- if ($existing_membership_id && $existing_membership_id !== (int) $membership->get_id()) { + if ($existing_membership_id && (int) $membership->get_id() !== $existing_membership_id) { return false; } - if ($existing_customer_id && $existing_customer_id !== (int) $membership->get_customer_id()) { + if ($existing_customer_id && (int) $membership->get_customer_id() !== $existing_customer_id) { return false; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@inc/managers/class-membership-manager.php` around lines 382 - 391, The comparisons use non-Yoda style; change both !== checks to Yoda conditions by placing the literal/method result on the left: replace "if ($existing_membership_id && $existing_membership_id !== (int) $membership->get_id())" with a Yoda-style check using "(int) $membership->get_id() !== $existing_membership_id", and similarly replace "if ($existing_customer_id && $existing_customer_id !== (int) $membership->get_customer_id())" with "(int) $membership->get_customer_id() !== $existing_customer_id"; keep the initial truthiness checks but ensure the casted method calls are on the left side of the !== comparisons so they follow the project's Yoda condition guideline.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@inc/managers/class-membership-manager.php`:
- Around line 382-391: The comparisons use non-Yoda style; change both !==
checks to Yoda conditions by placing the literal/method result on the left:
replace "if ($existing_membership_id && $existing_membership_id !== (int)
$membership->get_id())" with a Yoda-style check using "(int)
$membership->get_id() !== $existing_membership_id", and similarly replace "if
($existing_customer_id && $existing_customer_id !== (int)
$membership->get_customer_id())" with "(int) $membership->get_customer_id() !==
$existing_customer_id"; keep the initial truthiness checks but ensure the casted
method calls are on the left side of the !== comparisons so they follow the
project's Yoda condition guideline.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9267e118-c525-4d95-966d-43ef0fec3b83
📒 Files selected for processing (3)
assets/js/thank-you.jsinc/managers/class-membership-manager.phptests/WP_Ultimo/Managers/Membership_Manager_Test.php
Summary
Verification
Notes
aidevops.sh v3.20.57 plugin for OpenCode v1.17.4 with gpt-5.5 Merged via PR #1415 to main. |
Summary
Verification
php -l inc/managers/class-membership-manager.php && php -l tests/WP_Ultimo/Managers/Membership_Manager_Test.phpvendor/bin/phpcs inc/managers/class-membership-manager.php tests/WP_Ultimo/Managers/Membership_Manager_Test.phpnpx eslint assets/js/thank-you.js --ignore-pattern '*.min.js'git diff --checkok: true, clearedpending_site, and wrote matchingwu_membership_id,wu_customer_id, andwu_type=customer_owned.Notes
vendor/bin/phpunit --filter 'Membership_Manager_Test::test_check_pending_site_created'could not run in this checkout because/tmp/wordpress-tests-lib/includes/functions.phpis missing.npm run lint:js -- assets/js/thank-you.jsis not suitable here because the npm script ignores the file argument and lints the entire legacy asset tree; direct ESLint was used for the touched file.aidevops.sh v3.20.57 plugin for OpenCode v1.17.4 with gpt-5.5
Summary by CodeRabbit