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

main
Jordi Boggiano 3 years ago
parent 6f992a6ea3
commit e87a150f41
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -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;
}
}
}

@ -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);
}
$file->validateSchema(JsonFile::LAX_SCHEMA);
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);

Loading…
Cancel
Save