Skip to content

Commit 8676fe5

Browse files
authored
Merge pull request #700 from derrabus/bugfix/get-raw-data
Make library compatible with `composer/composer:^2.0.14`, do not call `InstalledVersions::getRawData()` (which introduces runtime side-effect in pure API)
2 parents 568e465 + b5ee473 commit 8676fe5

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"webimpress/safe-writer": "^2.2.0"
2626
},
2727
"conflict": {
28+
"composer/composer": "<2.0.14",
2829
"zendframework/zend-stdlib": "<3.2.1",
2930
"laminas/laminas-stdlib": "<3.2.1",
3031
"doctrine/annotations": "<1.6.1",

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ProxyManager/Generator/Util/IdentifierSuffixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ public static function getIdentifier(string $name): string
4848

4949
private static function loadBaseHashSalt(): string
5050
{
51-
return sha1(serialize(InstalledVersions::getRawData()));
51+
return sha1(serialize(InstalledVersions::getAllRawData()));
5252
}
5353
}

tests/ProxyManagerTest/Generator/Util/IdentifierSuffixerTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PHPUnit\Framework\TestCase;
99
use ProxyManager\Generator\Util\IdentifierSuffixer;
1010

11+
use function is_callable;
1112
use function serialize;
1213
use function sha1;
1314
use function strlen;
@@ -37,8 +38,14 @@ public function testGeneratesSuffixedIdentifiers(string $name): void
3738
*/
3839
public function testGeneratedSuffixDependsOnPackageInstalledVersions(string $name): void
3940
{
41+
$hashedData = sha1(serialize(
42+
is_callable([InstalledVersions::class, 'getAllRawData'])
43+
? InstalledVersions::getAllRawData()
44+
: InstalledVersions::getRawData()
45+
));
46+
4047
self::assertStringEndsWith(
41-
substr(sha1($name . sha1(serialize(InstalledVersions::getRawData()))), 0, 5),
48+
substr(sha1($name . $hashedData), 0, 5),
4249
IdentifierSuffixer::getIdentifier($name)
4350
);
4451
}

0 commit comments

Comments
 (0)