Skip to content

Commit

Permalink
Fix the handling of minified metadata responses
Browse files Browse the repository at this point in the history
  • Loading branch information
stof authored and robbieaverill committed Jan 24, 2022
1 parent e0b52b2 commit bc3a194
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -15,7 +15,8 @@
"php": "^7.4 || ^8.0",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"doctrine/inflector": "^1.0 || ^2.0",
"ext-json": "*"
"ext-json": "*",
"composer/metadata-minifier": "^1.0"
},
"require-dev": {
"phpspec/phpspec": "^6.0 || ^7.0",
Expand Down
15 changes: 2 additions & 13 deletions src/Packagist/Api/Result/Factory.php
Expand Up @@ -4,6 +4,7 @@

namespace Packagist\Api\Result;

use Composer\MetadataMinifier\MetadataMinifier;
use InvalidArgumentException;
use Packagist\Api\Result\Package\Author;
use Packagist\Api\Result\Package\Dist;
Expand Down Expand Up @@ -131,19 +132,6 @@ public function createPackageResults(array $package): Package
$version['name'] ??= '';
$version['type'] ??= '';

if (isset($version['conflict']) && !is_array($version['conflict'])) {
unset($version['conflict']);
}
if (isset($version['suggest']) && !is_array($version['suggest'])) {
unset($version['suggest']);
}
if (isset($version['replace']) && !is_array($version['replace'])) {
unset($version['replace']);
}
if (isset($version['provide']) && !is_array($version['provide'])) {
unset($version['provide']);
}

if (isset($version['authors']) && $version['authors']) {
foreach ($version['authors'] as $key => $author) {
// Cast some potentially null properties to empty strings
Expand Down Expand Up @@ -198,6 +186,7 @@ public function createComposer2PackagesResults(array $packages): array
$created = [];

foreach ($packages as $name => $package) {
$package = MetadataMinifier::expand($package);
// Create an empty package, only contains versions
$createdPackage = array(
'versions' => [],
Expand Down

0 comments on commit bc3a194

Please sign in to comment.