GH#1038: add _reload_done circuit-breaker to thank-you.js stopped branch#1040
Conversation
…gate Move Site_Exporter::get_instance() from the fully-loaded section (~line 584) to before the Requirements::met() / run_setup() early-return (~line 188). This ensures that all Site_Exporter functionality is available even when Ultimate Multisite is not fully configured: - Sites > Export & Import admin menu item is registered - Export/import row actions appear on the WordPress Sites page - Export/import form handlers and download endpoint are hooked - WP Ultimo-specific hooks (wu_export_site, wu_import_site, etc.) are also available for when WP Ultimo IS set up (no change in behaviour) The Singleton trait ensures init() runs exactly once, so hoisting the call is safe even though the fully-loaded boot path no longer calls it a second time. Resolves #1007
…orter::setup() WP-CLI performs command discovery early in its bootstrap process. The mu-migration command class files each end with a bare WP_CLI::add_command() call that fires at file-include time, but load_dependencies() was only ever called lazily from handle_site_export() / handle_site_import() - far too late for WP-CLI to discover them. Add an early call to load_dependencies() in setup() when WP_CLI is defined and truthy. This mirrors the pattern in inc/apis/trait-wp-cli.php (enable_wp_cli()) used by every other manager that registers WP-CLI commands. The require_once calls inside load_dependencies() are idempotent, so the lazy call from handle_site_export() remains harmless. Combined with the GH#1007 fix (Site_Exporter now loads before the requirements gate), this makes the commands available even when Ultimate Multisite is not fully set up - which is the primary migration use case. Resolves #1006
Add a one-time guard (_reload_done) around the window.location.reload() call in the Case 1 'stopped' branch of check_site_created(). Multiple setTimeout callbacks can be queued before the first reload fires during async polling overlap, potentially triggering redundant reloads. The guard is initialised to false in data() and set to true immediately before window.location.reload() is invoked, ensuring only the first queued callback performs the reload. Resolves #1038
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR addresses a boot-order issue and prevents unintended page reloads. It adds a reload guard in the thank-you page script, moves Site Exporter initialization earlier in the WordPress init sequence, and implements eager dependency loading for WP-CLI command discovery during bootstrap. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
Merge SummaryIssue: #1038 — quality-debt: PR #972 review feedback (medium) What changed
WhyMultiple VerificationJS syntax validated via |
🔨 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: |
|
Performance Test Results Performance test results for 69375cd 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:
|
🔨 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: |
Summary
Add a
_reload_donecircuit-breaker flag to prevent multiplewindow.location.reload()calls in thecheck_site_created()"stopped" branch ofassets/js/thank-you.js.Problem
In the Case 1 path (
running_count > 0in the stopped branch), the unconditionalwindow.location.reload()could fire multiple times if severalsetTimeoutcallbacks were queued before the first reload cleared the page. Each queued callback would re-enter the same branch and call reload again.Fix
_reload_done: falseto the Vuedata()object with an explanatory comment.window.location.reload()call:if (this.running_count > 0 && !this._reload_done).this._reload_done = trueimmediately before invokingwindow.location.reload(), ensuring only the first callback triggers the reload.The other branches (
site_ready,creating, Case 2, Case 3) are left unchanged as specified in the review feedback.Verification
node -e "new Function(src)"passes._reload_doneisfalse→ reload fires and flag is set; any subsequent callback sees_reload_done === trueand falls through (no-op), preventing duplicate navigations.Resolves #1038
aidevops.sh v3.13.12 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 3m and 5,058 tokens on this as a headless worker.
Summary by CodeRabbit