Fix regression with non-SPDX licenses in show command, refs #3885

main
Jordi Boggiano 9 years ago
parent 99694a0381
commit 921b3a0eba

@ -392,12 +392,16 @@ EOT
foreach ($licenses as $licenseId) { foreach ($licenses as $licenseId) {
$license = $spdxLicense->getLicenseByIdentifier($licenseId); // keys: 0 fullname, 1 osi, 2 url $license = $spdxLicense->getLicenseByIdentifier($licenseId); // keys: 0 fullname, 1 osi, 2 url
if (!$license) {
$out = $licenseId;
} else {
// is license OSI approved? // is license OSI approved?
if ($license[1] === true) { if ($license[1] === true) {
$out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]); $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
} else { } else {
$out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]); $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
} }
}
$this->getIO()->write('<info>license</info> : ' . $out); $this->getIO()->write('<info>license</info> : ' . $out);
} }

@ -49,10 +49,14 @@ class SpdxLicense
* *
* @param string $identifier * @param string $identifier
* *
* @return array * @return array|false
*/ */
public function getLicenseByIdentifier($identifier) public function getLicenseByIdentifier($identifier)
{ {
if (!isset($this->licenses[$identifier])) {
return false;
}
$license = $this->licenses[$identifier]; $license = $this->licenses[$identifier];
// add URL for the license text (it's not included in the json) // add URL for the license text (it's not included in the json)

Loading…
Cancel
Save