1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-22 07:20:11 +02:00

[ticket/11150] Preserve original requirements and avoid finally

PHPBB3-11150
This commit is contained in:
Tristan Darricau 2015-09-12 16:05:19 +02:00 committed by Tristan Darricau
parent e3fadc1fc7
commit 8a1ca4375e
No known key found for this signature in database
GPG Key ID: 817043C2E29DB881

@ -119,20 +119,19 @@ class installer
->setRunScripts(false) ->setRunScripts(false)
->setDryRun(false); ->setDryRun(false);
$result = 0;
try try
{ {
$result = $install->run(); $result = $install->run();
putenv('COMPOSER_VENDOR_DIR=' . $original_vendor_dir);
//$output = $io->getOutput(); //$output = $io->getOutput();
//$error_pos = strpos($output, 'Your requirements could not be resolved to an installable set of packages.'); //$error_pos = strpos($output, 'Your requirements could not be resolved to an installable set of packages.');
} }
catch (\Exception $e) catch (\Exception $e)
{ {
throw new runtime_exception('Cannot install packages', [], $e);
}
finally
{
putenv('COMPOSER_VENDOR_DIR=' . $original_vendor_dir); putenv('COMPOSER_VENDOR_DIR=' . $original_vendor_dir);
throw new runtime_exception('Cannot install packages', [], $e);
} }
if ($result !== 0) if ($result !== 0)
@ -161,25 +160,24 @@ class installer
$composer = Factory::create($io, $this->get_composer_ext_json_filename(), false); $composer = Factory::create($io, $this->get_composer_ext_json_filename(), false);
$installed = []; $installed = [];
$packages = $composer->getPackage()->getRequires();//$composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages(); $required_links = $composer->getPackage()->getRequires();
$installed_packages = $composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
foreach ($packages as $package) foreach ($installed_packages as $package)
{ {
if (in_array($package->getType(), $types, true)) if (array_key_exists($package->getName(), $required_links) && in_array($package->getType(), $types, true))
{ {
$installed[$package->getName()] = $package->getPrettyVersion(); $installed[$package->getName()] = $required_links[$package->getName()]->getPrettyConstraint();
} }
} }
putenv('COMPOSER_VENDOR_DIR=' . $original_vendor_dir);
return $installed; return $installed;
} }
catch (\Exception $e) catch (\Exception $e)
{
return [];
}
finally
{ {
putenv('COMPOSER_VENDOR_DIR=' . $original_vendor_dir); putenv('COMPOSER_VENDOR_DIR=' . $original_vendor_dir);
return [];
} }
} }