Bug
The mu-migration ImportCommand::tables() method (line 292-293) requires sed to be installed for database prefix replacement:
// Terminates the script if sed is not installed.
$this->check_for_sed_presence(true);
And replace_db_prefix() (line 685-715) uses sed via WP_CLI::launch():
$full_command = "sed '$sed_command' -i $filename";
$sed_result = \WP_CLI::launch($full_command, false, false);
However, in the web/AJAX context (non-CLI):
WP_CLI::launch() is not available — the polyfill in helpers.php covers db tables, db export, db import, and search-replace, but NOT sed operations
- The
check_for_sed_presence() method calls WP_CLI::launch('echo "wp_" | sed ...') which will crash in web context
- Even if
sed is available on the system, the web user (www-data) may not have the same PATH
This means database prefix replacement during import is completely broken in web context.
Impact
Admin UI imports (which run in web/AJAX context) will crash when importing a site that has a different database prefix from the target site — which is the normal case for cross-network migrations.
Suggested Fix
Replace the sed dependency with a pure PHP string replacement using str_replace() or preg_replace() on the SQL file content. The replace_db_prefix() method does simple string substitution that doesn't require sed at all.
Files to modify
EDIT: inc/site-exporter/mu-migration/includes/commands/class-mu-migration-import.php:685-715 — replace sed calls with PHP str_replace
EDIT: inc/site-exporter/mu-migration/includes/commands/class-mu-migration-import.php:292-293 — remove sed presence check for web context
Severity
High — database imports from different prefix sources fail in web context.
aidevops.sh v3.13.11 plugin for OpenCode v1.3.17 with claude-opus-4-6 spent 8m and 17,664 tokens on this as a headless worker.
Bug
The mu-migration
ImportCommand::tables()method (line 292-293) requiressedto be installed for database prefix replacement:And
replace_db_prefix()(line 685-715) usessedviaWP_CLI::launch():However, in the web/AJAX context (non-CLI):
WP_CLI::launch()is not available — the polyfill inhelpers.phpcoversdb tables,db export,db import, andsearch-replace, but NOTsedoperationscheck_for_sed_presence()method callsWP_CLI::launch('echo "wp_" | sed ...')which will crash in web contextsedis available on the system, the web user (www-data) may not have the same PATHThis means database prefix replacement during import is completely broken in web context.
Impact
Admin UI imports (which run in web/AJAX context) will crash when importing a site that has a different database prefix from the target site — which is the normal case for cross-network migrations.
Suggested Fix
Replace the
seddependency with a pure PHP string replacement usingstr_replace()orpreg_replace()on the SQL file content. Thereplace_db_prefix()method does simple string substitution that doesn't require sed at all.Files to modify
EDIT: inc/site-exporter/mu-migration/includes/commands/class-mu-migration-import.php:685-715— replace sed calls with PHP str_replaceEDIT: inc/site-exporter/mu-migration/includes/commands/class-mu-migration-import.php:292-293— remove sed presence check for web contextSeverity
High — database imports from different prefix sources fail in web context.
aidevops.sh v3.13.11 plugin for OpenCode v1.3.17 with claude-opus-4-6 spent 8m and 17,664 tokens on this as a headless worker.