Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions includes/commands/class-mu-migration-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,17 @@ private function move_and_activate_plugins( $plugins_dir, $plugins, $blog_plugin

if ( ! file_exists( $installed_plugins . '/' . $plugin_folder ) ) {
WP_CLI::log( sprintf( __( 'Moving %s to plugins folder' ), $plugin_name ) );
rename( $fullPluginPath, $installed_plugins . '/' . $plugin_folder );

/**
* PHP has a core bug that prevents rename() from working reliably across filesystems.
* We'll disable and replace rename() by exec() calls.
*
* @link https://stackoverflow.com/a/35503748/2209086
* @link https://bugs.php.net/bug.php?id=54097
*/
// rename( $fullPluginPath, $installed_plugins . '/' . $plugin_folder );

exec("mv " . escapeshellarg($fullPluginPath) . " " . escapeshellarg($installed_plugins . '/' . $plugin_folder));
}

if ( $check_plugins && in_array( $plugin_name, $blog_plugins, true ) ) {
Expand Down Expand Up @@ -619,7 +629,18 @@ private function move_themes( $themes_dir ) {

if ( ! file_exists( $installed_themes . '/' . $theme->getFilename() ) ) {
WP_CLI::log( sprintf( __( 'Moving %s to themes folder' ), $theme->getFilename() ) );
rename( $fullPluginPath, $installed_themes . '/' . $theme->getFilename() );

/**
* PHP has a core bug that prevents rename() from working reliably across filesystems.
* We'll disable and replace rename() by exec() calls.
*
* @link https://stackoverflow.com/a/35503748/2209086
* @link https://bugs.php.net/bug.php?id=54097
*/
// rename( $fullPluginPath, $installed_themes . '/' . $theme->getFilename() );

exec("mv " . escapeshellarg($fullPluginPath) . " " . escapeshellarg($installed_themes . '/' . $theme->getFilename()));


Helpers\runcommand( 'theme enable', [ $theme->getFilename() ] );
}
Expand All @@ -644,7 +665,22 @@ private function create_new_site( $meta_data ) {
return false;
}

$blog_id = insert_blog( $parsed_url['host'], $parsed_url['path'], $site_id );
$now = current_time( 'mysql', true );
$new_site_meta = array(
'domain' => $parsed_url['host'],
'path' => $parsed_url['path'],
'network_id' => $site_id,
'registered' => $now,
'last_updated' => $now,
'public' => 1,
'archived' => 0,
'mature' => 0,
'spam' => 0,
'deleted' => 0,
'lang_id' => 0,
);

$blog_id = wp_insert_site( $new_site_meta );

if ( ! $blog_id ) {
return false;
Expand Down