GH#1006 GH#1007: fix: WP-CLI command registration + Site_Exporter before requirements gate#1036
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
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 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 46 minutes and 8 seconds.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: |
🔨 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 c5a94c4 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:
|
What was doneFixed the GH#1006 — WP-CLI commands not registeredThe mu-migration class files each end with a bare GH#1007 — Site_Exporter not loaded before requirements gate
Files changed
VerificationAll CI checks passed: PHP 8.2–8.5, Code Quality, E2E (Cypress), PHP Lint. |
Summary
This PR combines two closely related fixes for the Site Exporter:
load_dependencies()was called too late for WP-CLI command discoveryThese two issues compound each other: #1007 means the Site_Exporter never loads in migration scenarios; #1006 means even when it does load, the WP-CLI commands are never registered.
Changes
EDIT: inc/class-wp-ultimo.php(GH#1007)\WP_Ultimo\Site_Exporter\Site_Exporter::get_instance()from the fully-loaded section (~line 584) to immediately before the requirements gateEDIT: inc/site-exporter/class-site-exporter.php(GH#1006)load_dependencies()call insetup()guarded bydefined('WP_CLI') && WP_CLIWP_CLI::add_command()call that fires at include-time; callingload_dependencies()early ensures these run before WP-CLI finishes its bootstrap phaserequire_oncecalls insideload_dependencies()are idempotent, so the lazy call fromhandle_site_export()is harmlessTesting
Resolves #1006
Resolves #1007