1
0
Fork 0

Make sure schema issues are always reported correctly, but not in init when Composer is not required, fixes #9986

pull/9991/head
Jordi Boggiano 2021-06-27 14:31:50 +02:00
parent 6f992a6ea3
commit e87a150f41
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 11 additions and 4 deletions

View File

@ -420,9 +420,9 @@ class Application extends BaseApplication
exit(1);
}
} catch (JsonValidationException $e) {
$errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
$message = $e->getMessage() . ':' . PHP_EOL . $errors;
throw new JsonValidationException($message);
if ($required) {
throw $e;
}
}
}

View File

@ -37,6 +37,7 @@ use Composer\EventDispatcher\EventDispatcher;
use Composer\Autoload\AutoloadGenerator;
use Composer\Package\Version\VersionParser;
use Composer\Downloader\TransportException;
use Composer\Json\JsonValidationException;
use Seld\JsonLint\JsonParser;
/**
@ -308,7 +309,13 @@ class Factory
throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
}
try {
$file->validateSchema(JsonFile::LAX_SCHEMA);
} catch (JsonValidationException $e) {
$errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
$message = $e->getMessage() . ':' . PHP_EOL . $errors;
throw new JsonValidationException($message);
}
$jsonParser = new JsonParser;
try {
$jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);