fix: load site exporter in web requests#1541
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe site exporter now catches MU-Migration runtime exceptions during import, loads a WP-CLI polyfill when CLI classes are absent, and adds a subprocess test for loading the export command stack without WP-CLI. ChangesMU-CLI fallback loading
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/WP_Ultimo/Site_Exporter_Test.php (1)
312-325: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGuard the subprocess test against disabled
shell_exec/emptyPHP_BINARY.In hardened CI/runtime environments
shell_execcan be disabled (orPHP_BINARYempty), in which case$outputisnulland the test fails for an environmental reason rather than a real regression. A skip guard makes intent clear. (The OpenGrep/ast-grep command-injection hints here are false positives — bothPHP_BINARYand$scriptare passed throughescapeshellarg().)🧪 Proposed skip guard
public function test_mu_migration_export_commands_load_without_wp_cli_runtime(): void { + + if (! function_exists('shell_exec') || '' === PHP_BINARY) { + $this->markTestSkipped('shell_exec or PHP_BINARY is not available in this environment'); + } $repo_root = dirname(__DIR__, 2);🤖 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 `@tests/WP_Ultimo/Site_Exporter_Test.php` around lines 312 - 325, The subprocess regression test in test_mu_migration_export_commands_load_without_wp_cli_runtime should be skipped when the environment cannot run it, such as when shell_exec is disabled or PHP_BINARY is unavailable. Add an early guard before building the shell command, and use the test case’s skip mechanism so the assertion only runs when the spawned PHP process can actually execute. Keep the existing shell_exec call and assertions in place for the valid path, using the same test method and related MU_Migration command class references to locate the change.
🤖 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.
Inline comments:
In `@inc/site-exporter/mu-migration/includes/wp-cli-polyfill.php`:
- Around line 90-93: Wrap the site import execution in explicit error handling
because WP_CLI::error() in the polyfill throws a RuntimeException during
web/AJAX imports. Update handle_site_import() to catch that exception around the
$command->all([$file_name], $args) call and handle the failure gracefully
instead of letting it bubble into a fatal, and review the invalid-input paths
that still call WP_CLI::error() so the import flow in class-site-exporter stays
safe in non-CLI runs.
---
Nitpick comments:
In `@tests/WP_Ultimo/Site_Exporter_Test.php`:
- Around line 312-325: The subprocess regression test in
test_mu_migration_export_commands_load_without_wp_cli_runtime should be skipped
when the environment cannot run it, such as when shell_exec is disabled or
PHP_BINARY is unavailable. Add an early guard before building the shell command,
and use the test case’s skip mechanism so the assertion only runs when the
spawned PHP process can actually execute. Keep the existing shell_exec call and
assertions in place for the valid path, using the same test method and related
MU_Migration command class references to locate the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f178c4c6-602b-4574-aafe-c1b4aa81deee
📒 Files selected for processing (3)
inc/site-exporter/class-site-exporter.phpinc/site-exporter/mu-migration/includes/wp-cli-polyfill.phptests/WP_Ultimo/Site_Exporter_Test.php
Summary
Verification
NotesThe merged #1540 commit is in aidevops.sh v3.22.1 plugin for OpenCode v1.17.9 with gpt-5.5 Merged via PR #1541 to main. |
🔨 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: |
|
CLAIM_RELEASED reason=worker_complete runner=superdav42 ts=2026-06-25T21:07:14Z aidevops_version=3.22.1 opencode_version=1.17.9 |
Summary
WP_CLI_Command/WP_CLIare unavailablemu-migration infocommand loaded only during real WP-CLI requestsVerification
vendor/bin/phpunit --filter 'Site_Exporter_Test|Site_Exporter_Round_Trip_Test|Site_Exporter_Import_Move_Test'vendor/bin/phpcs inc/site-exporter/class-site-exporter.php inc/site-exporter/mu-migration/includes/wp-cli-polyfill.php tests/WP_Ultimo/Site_Exporter_Test.phpvendor/bin/phpstan analyse inc/site-exporter/class-site-exporter.php inc/site-exporter/mu-migration/includes/wp-cli-polyfill.php tests/WP_Ultimo/Site_Exporter_Test.phpNotes
The merged #1540 commit is in
main, but the web/AJAX fatal fix was pushed afterward and did not land inmain. This PR contains only that follow-up fix on top of currentmain.aidevops.sh v3.22.1 plugin for OpenCode v1.17.9 with gpt-5.5
Summary by CodeRabbit