Skip to content

Commit

Permalink
Merge pull request #440 from Sebobo/bugfix/version-sorting
Browse files Browse the repository at this point in the history
BUGFIX: Prevent lower version from appearing as package search result
  • Loading branch information
regniets committed Jul 18, 2022
2 parents 48dbcd5 + 7046c01 commit 389de2d
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,10 @@ public function extractVersions(NodeInterface $node): array
public function extractLastVersion(NodeInterface $node): ?NodeInterface
{
$versions = $this->extractVersions($node);
usort($versions, static function(NodeInterface $a, NodeInterface $b) {
/** @var \DateTime $aTime */
$aTime = $a->getProperty('time');
/** @var \DateTime $bTime */
$bTime = $b->getProperty('time');
if ($aTime === false || $bTime === false) {
return -1;
}
return $bTime->getTimestamp() - $aTime->getTimestamp();
usort($versions, static function (NodeInterface $a, NodeInterface $b) {
return $a->getProperty('versionNormalized') <=> $b->getProperty('versionNormalized');
});
$stableVersions = array_filter($versions, static function(NodeInterface $version) {
$stableVersions = array_filter($versions, static function (NodeInterface $version) {
return $version->getProperty('stability') === true;
});
if (count($stableVersions) > 0) {
Expand Down

0 comments on commit 389de2d

Please sign in to comment.