Skip to content

Commit

Permalink
feat: make sure the APCU autoloader prefix is deterministic when a `c…
Browse files Browse the repository at this point in the history
…omposer.lock` file is available
  • Loading branch information
drupol committed May 5, 2024
1 parent 2fe3244 commit acbdcb5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Composer/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,12 @@ public function run(): int
}

$this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
$this->autoloadGenerator->setApcu($this->apcuAutoloader, $this->apcuAutoloaderPrefix);
$this->autoloadGenerator->setApcu(
$this->apcuAutoloader,
$this->apcuAutoloaderPrefix === null
? ($this->locker !== null && $this->locker->isLocked() ? $this->locker->getLockData()['content-hash'] : null)
: $this->apcuAutoloaderPrefix
);
$this->autoloadGenerator->setRunScripts($this->runScripts);
$this->autoloadGenerator->setPlatformRequirementFilter($this->platformRequirementFilter);
$this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Install from a lock file that deleted a package
}
--LOCK--
{
"content-hash": "4c3b9426f087ef6dc15cc81ef697f162",
"packages": [
{ "name": "allowed/pkg", "version": "1.1.0" },
{ "name": "fixed/dependency", "version": "1.0.0" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Installing an old alias that doesn't exist anymore from a lock is possible
}
--LOCK--
{
"content-hash": "4c3b9426f087ef6dc15cc81ef697f162",
"packages": [
{
"name": "a/a", "version": "dev-master", "version_normalized": "9999999-dev",
Expand Down
1 change: 1 addition & 0 deletions tests/Composer/Test/Fixtures/installer/suggest-prod.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Suggestions are not displayed for when not updating the lock file
}
--LOCK--
{
"content-hash": "4c3b9426f087ef6dc15cc81ef697f162",
"packages": [
{ "name": "a/a", "version": "1.0.0", "suggest": { "b/b": "an obscure reason" } }
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Installing locked dev packages should remove old dependencies
}
--LOCK--
{
"content-hash": "4c3b9426f087ef6dc15cc81ef697f162",
"packages": [
{
"name": "a/devpackage", "version": "dev-master",
Expand Down

0 comments on commit acbdcb5

Please sign in to comment.