Skip to content

Commit 233caf6

Browse files
Merge pull request #75 from stof/fix_metadata_v2
Fix the handling of minified metadata responses
2 parents e0b52b2 + b8eeec1 commit 233caf6

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Tests and linting
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"php": "^7.4 || ^8.0",
1616
"guzzlehttp/guzzle": "^6.0 || ^7.0",
1717
"doctrine/inflector": "^1.0 || ^2.0",
18-
"ext-json": "*"
18+
"ext-json": "*",
19+
"composer/metadata-minifier": "^1.0"
1920
},
2021
"require-dev": {
2122
"phpspec/phpspec": "^6.0 || ^7.0",

src/Packagist/Api/Result/Factory.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Packagist\Api\Result;
66

7+
use Composer\MetadataMinifier\MetadataMinifier;
78
use InvalidArgumentException;
89
use Packagist\Api\Result\Package\Author;
910
use Packagist\Api\Result\Package\Dist;
@@ -131,19 +132,6 @@ public function createPackageResults(array $package): Package
131132
$version['name'] ??= '';
132133
$version['type'] ??= '';
133134

134-
if (isset($version['conflict']) && !is_array($version['conflict'])) {
135-
unset($version['conflict']);
136-
}
137-
if (isset($version['suggest']) && !is_array($version['suggest'])) {
138-
unset($version['suggest']);
139-
}
140-
if (isset($version['replace']) && !is_array($version['replace'])) {
141-
unset($version['replace']);
142-
}
143-
if (isset($version['provide']) && !is_array($version['provide'])) {
144-
unset($version['provide']);
145-
}
146-
147135
if (isset($version['authors']) && $version['authors']) {
148136
foreach ($version['authors'] as $key => $author) {
149137
// Cast some potentially null properties to empty strings
@@ -198,6 +186,7 @@ public function createComposer2PackagesResults(array $packages): array
198186
$created = [];
199187

200188
foreach ($packages as $name => $package) {
189+
$package = MetadataMinifier::expand($package);
201190
// Create an empty package, only contains versions
202191
$createdPackage = array(
203192
'versions' => [],

0 commit comments

Comments
 (0)