ClassicPress / ClassicPress-Migration-Plugin

Switch your WordPress installation to ClassicPress.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle existing composer.json better

nylen opened this issue · comments

Currently attempting a migration with an existing composer.json file will block the migration with an error that is not very clear (see #53), and this is fairly common.

Two example causes are when ClassicPress has previously been installed, and (potentially, clue from Slack discussion today) when WordPress was installed via Softaculous.

Another potential cause (and the reason we put this message in place) is that composer.json could be actually in use and valuable to the site, but it seems to be more common that this is a red herring.

We should change this "conflicting files" logic to do something like the following:

We detected an existing composer.json file, which will be overwritten during migration. A backup will be saved to composer.json.bak

switching to .bak2 etc if a previous backup already exists.

The current "conflicting files" logic only applies for composer.json, for reference:

function classicpress_check_conflicting_files() {
$files = array(
'composer.json',
);
$conflict = array();
foreach ( $files as $file ) {
if ( file_exists( ABSPATH . $file ) ) {
$conflict[] = $file;
}
}
return $conflict;
}

This is fixed in 627a664 and the new plugin release 1.1.0. Responsibility for backing up composer.json (if needed) has been shifted to the user:

2019-10-24T20-35-19Z