Skip to content

Commit 6746c8f

Browse files
committed
experiment: add root requires to list of all platform requirements
1 parent 1f5ec49 commit 6746c8f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

support/installer/src/ComposerInstallerPlugin.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Composer\Installer\PackageEvent;
1010
use Composer\Installer\PackageEvents;
1111
use Composer\Package\PackageInterface;
12+
use Composer\Package\RootPackageInterface;
1213
use Composer\Util\Filesystem;
1314
use Composer\Util\ProcessExecutor;
1415

@@ -92,7 +93,7 @@ public function onPostPackageInstall(PackageEvent $event)
9293
// first, load all platform requirements from all operations
9394
// this is because if a package requires `ext-bcmath`, which is `replace`d by `php`, no install event is generated for `ext-bcmath`, but we still need to enable it
9495
// we cannot do this via InstallerEvents::PRE_OPERATIONS_EXEC, as that fires before this plugin is even installed
95-
$this->initAllPlatformRequirements($event->getOperations());
96+
$this->initAllPlatformRequirements($event->getComposer()->getPackage(), $event->getOperations());
9697

9798
$package = $event->getOperation()->getPackage();
9899

@@ -131,7 +132,7 @@ public function onPostPackageInstall(PackageEvent $event)
131132
// since this is, realistically, only used by PHP (for its bundled shared extensions), we can probably remove this in the future; however, doing this without a BC break would require bumping the installer version to 2.0, which (even if we fully re-built our own repositories) would break third-party repositories
132133
// the alternative will be to remove this in e.g. v1.7 or v1.8, and adding deprecation warnings beforehand, in order to warn the (few, if any) users that have custom repositories with their own builds of PHP
133134
// TODO: potentially remove this in a future version, but recordUserlandProvides() now uses this as well to speed up ".native" extension variant installs (by skipping unnecessary attempts)
134-
protected function initAllPlatformRequirements(array $operations)
135+
protected function initAllPlatformRequirements(RootPackageInterface $rootPackage, array $operations)
135136
{
136137
if($this->allPlatformRequirements !== null) return;
137138

@@ -147,6 +148,11 @@ protected function initAllPlatformRequirements(array $operations)
147148
}
148149
}
149150
}
151+
foreach($rootPackage->getRequires() as $require) {
152+
if(strpos($require->getTarget(), 'heroku-sys/') === 0) {
153+
$this->allPlatformRequirements[$require->getTarget()] = $require->getSource();
154+
}
155+
}
150156
}
151157

152158
public function recordUserlandProvides(PackageInterface $package)

0 commit comments

Comments
 (0)