Skip to content

Commit 8a1ca43

Browse files
Tristan DarricauNicofuma
authored andcommitted
[ticket/11150] Preserve original requirements and avoid finally
PHPBB3-11150
1 parent e3fadc1 commit 8a1ca43

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

phpBB/phpbb/composer/installer.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,19 @@ public function install(array $packages, $whitelist, IOInterface $io = null)
119119
->setRunScripts(false)
120120
->setDryRun(false);
121121

122-
$result = 0;
123122
try
124123
{
125124
$result = $install->run();
125+
126+
putenv('COMPOSER_VENDOR_DIR=' . $original_vendor_dir);
126127
//$output = $io->getOutput();
127128
//$error_pos = strpos($output, 'Your requirements could not be resolved to an installable set of packages.');
128129
}
129130
catch (\Exception $e)
130131
{
131-
throw new runtime_exception('Cannot install packages', [], $e);
132-
}
133-
finally
134-
{
132+
135133
putenv('COMPOSER_VENDOR_DIR=' . $original_vendor_dir);
134+
throw new runtime_exception('Cannot install packages', [], $e);
136135
}
137136

138137
if ($result !== 0)
@@ -161,25 +160,24 @@ public function get_installed_packages($types)
161160
$composer = Factory::create($io, $this->get_composer_ext_json_filename(), false);
162161

163162
$installed = [];
164-
$packages = $composer->getPackage()->getRequires();//$composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
163+
$required_links = $composer->getPackage()->getRequires();
164+
$installed_packages = $composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
165165

166-
foreach ($packages as $package)
166+
foreach ($installed_packages as $package)
167167
{
168-
if (in_array($package->getType(), $types, true))
168+
if (array_key_exists($package->getName(), $required_links) && in_array($package->getType(), $types, true))
169169
{
170-
$installed[$package->getName()] = $package->getPrettyVersion();
170+
$installed[$package->getName()] = $required_links[$package->getName()]->getPrettyConstraint();
171171
}
172172
}
173173

174+
putenv('COMPOSER_VENDOR_DIR=' . $original_vendor_dir);
174175
return $installed;
175176
}
176177
catch (\Exception $e)
177-
{
178-
return [];
179-
}
180-
finally
181178
{
182179
putenv('COMPOSER_VENDOR_DIR=' . $original_vendor_dir);
180+
return [];
183181
}
184182
}
185183

0 commit comments

Comments
 (0)