1
0
Fork 0

Rollback changes in case the installer fails in remove/require commands, fixes #3464

pull/4974/head
Jordi Boggiano 2016-02-27 16:58:45 +00:00
parent b9a3ef73c0
commit 823266407f
2 changed files with 18 additions and 2 deletions

View File

@ -116,11 +116,19 @@ EOT
->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
; ;
$exception = null;
try {
$status = $install->run(); $status = $install->run();
} catch (\Exception $exception) {
$status = 1;
}
if ($status !== 0) { if ($status !== 0) {
$io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>'); $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
file_put_contents($jsonFile->getPath(), $composerBackup); file_put_contents($jsonFile->getPath(), $composerBackup);
} }
if ($exception) {
throw $exception;
}
return $status; return $status;
} }

View File

@ -165,7 +165,12 @@ EOT
->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
; ;
$exception = null;
try {
$status = $install->run(); $status = $install->run();
} catch (\Exception $exception) {
$status = 1;
}
if ($status !== 0) { if ($status !== 0) {
if ($newlyCreated) { if ($newlyCreated) {
$io->writeError("\n".'<error>Installation failed, deleting '.$file.'.</error>'); $io->writeError("\n".'<error>Installation failed, deleting '.$file.'.</error>');
@ -175,6 +180,9 @@ EOT
file_put_contents($json->getPath(), $composerBackup); file_put_contents($json->getPath(), $composerBackup);
} }
} }
if ($exception) {
throw $exception;
}
return $status; return $status;
} }