diff --git a/markdown.install b/markdown.install index 5dcc1f703d171cdd9fbeb42a7634ab1d038da235..293027628638ac797e3ed6909c5926d7dfe3427d 100644 --- a/markdown.install +++ b/markdown.install @@ -147,7 +147,7 @@ function markdown_requirements($phase) { else { $severity = REQUIREMENT_OK; $statuses = []; - foreach ($installed as $parserId => $parser) { + foreach ($enabled as $parser) { $library = $parser->getInstalledLibrary(); $status = (string) $library->getStatus(); if (!isset($statuses[$status])) { @@ -167,10 +167,19 @@ function markdown_requirements($phase) { } $value = ''; - foreach ($statuses as $status => $count) { - $value .= $translation->formatPlural($count, '1 %status parser', '@count %status parsers', [ - '%status' => $status, - ]); + if (!empty($statuses)) { + $value .= match ($severity) { + REQUIREMENT_ERROR, REQUIREMENT_WARNING => $translation->translate('The following issues exist:'), + default => $translation->translate('Markdown parser status:'), + }; + + $value .= '<ul>'; + foreach ($statuses as $status => $count) { + $value .= '<li>' . $translation->formatPlural($count, '1 %status parser', '@count %status parsers', [ + '%status' => $status, + ]) . '</li>'; + } + $value .= '</ul>'; } $requirements['markdown']['severity'] = $severity; diff --git a/src/Annotation/ComposerPackage.php b/src/Annotation/ComposerPackage.php index 625f095cd934c8d12282d8095a76cfc4486e42eb..ae91e804a165c4f064d4de088457161ed99f5ed7 100644 --- a/src/Annotation/ComposerPackage.php +++ b/src/Annotation/ComposerPackage.php @@ -48,12 +48,13 @@ class ComposerPackage extends InstallableLibrary { if (!isset($this->availableVersions)) { $this->availableVersions = []; $id = $this->getId(); - // To ensure we have the latest versions at all times, use the - // https://repo.packagist.org/p/[vendor]/[package].json URL which are - // static files and not cached. - $json = $this->requestJson(sprintf('https://repo.packagist.org/p/%s.json', $id)); + // Get latest versions from the API. + // See https://packagist.org/apidoc#get-package-data. + $json = $this->requestJson(sprintf('https://repo.packagist.org/p2/%s.json', $id)); if (!empty($json['packages'][$id])) { - $this->availableVersions = array_keys($json['packages'][$id]); + foreach ($json['packages'][$id] as $package) { + $this->availableVersions[] = $package['version']; + } } } return $this->availableVersions;