Skip to content

Commit

Permalink
Merge pull request #700 from derrabus/bugfix/get-raw-data
Browse files Browse the repository at this point in the history
Make library compatible with `composer/composer:^2.0.14`, do not call `InstalledVersions::getRawData()` (which introduces runtime side-effect in pure API)
  • Loading branch information
Ocramius committed May 25, 2021
2 parents 568e465 + b5ee473 commit 8676fe5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -25,6 +25,7 @@
"webimpress/safe-writer": "^2.2.0"
},
"conflict": {
"composer/composer": "<2.0.14",
"zendframework/zend-stdlib": "<3.2.1",
"laminas/laminas-stdlib": "<3.2.1",
"doctrine/annotations": "<1.6.1",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ProxyManager/Generator/Util/IdentifierSuffixer.php
Expand Up @@ -48,6 +48,6 @@ public static function getIdentifier(string $name): string

private static function loadBaseHashSalt(): string
{
return sha1(serialize(InstalledVersions::getRawData()));
return sha1(serialize(InstalledVersions::getAllRawData()));
}
}
Expand Up @@ -8,6 +8,7 @@
use PHPUnit\Framework\TestCase;
use ProxyManager\Generator\Util\IdentifierSuffixer;

use function is_callable;
use function serialize;
use function sha1;
use function strlen;
Expand Down Expand Up @@ -37,8 +38,14 @@ public function testGeneratesSuffixedIdentifiers(string $name): void
*/
public function testGeneratedSuffixDependsOnPackageInstalledVersions(string $name): void
{
$hashedData = sha1(serialize(
is_callable([InstalledVersions::class, 'getAllRawData'])
? InstalledVersions::getAllRawData()
: InstalledVersions::getRawData()
));

self::assertStringEndsWith(
substr(sha1($name . sha1(serialize(InstalledVersions::getRawData()))), 0, 5),
substr(sha1($name . $hashedData), 0, 5),
IdentifierSuffixer::getIdentifier($name)
);
}
Expand Down

0 comments on commit 8676fe5

Please sign in to comment.