mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-11 22:08:54 +00:00
[ticket/17336] Optimize version sorting
PHPBB-17336 Signed-off-by: Matt Friedman <maf675@gmail.com>
This commit is contained in:
parent
d8aa3f05e5
commit
5229813c47
1 changed files with 14 additions and 12 deletions
|
@ -24,7 +24,6 @@ use Composer\Json\JsonValidationException;
|
||||||
use Composer\Package\BasePackage;
|
use Composer\Package\BasePackage;
|
||||||
use Composer\Package\CompleteAliasPackage;
|
use Composer\Package\CompleteAliasPackage;
|
||||||
use Composer\Package\CompletePackage;
|
use Composer\Package\CompletePackage;
|
||||||
use Composer\Package\Version\VersionParser;
|
|
||||||
use Composer\PartialComposer;
|
use Composer\PartialComposer;
|
||||||
use Composer\Repository\ComposerRepository;
|
use Composer\Repository\ComposerRepository;
|
||||||
use Composer\Semver\Constraint\ConstraintInterface;
|
use Composer\Semver\Constraint\ConstraintInterface;
|
||||||
|
@ -395,20 +394,23 @@ class installer
|
||||||
/** @var CompletePackage|CompleteAliasPackage $highest_version */
|
/** @var CompletePackage|CompleteAliasPackage $highest_version */
|
||||||
$highest_version = null;
|
$highest_version = null;
|
||||||
|
|
||||||
/** @var CompletePackage|CompleteAliasPackage $version */
|
// Sort the versions array in descending order
|
||||||
foreach ($versions as $version)
|
usort($versions, function ($a, $b)
|
||||||
{
|
{
|
||||||
if (!$highest_version || version_compare($version->getVersion(), $highest_version->getVersion(), '>'))
|
return version_compare($b->getVersion(), $a->getVersion());
|
||||||
{
|
});
|
||||||
$highest_version = $version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If highest version is DEFAULT_BRANCH_ALIAS (9999999-dev), then it's a non-numeric dev branch handled by
|
// The first element in the sorted array is the highest version
|
||||||
// an Alias, so we need to get the actual package being aliased in order to show the true non-numeric version.
|
if (!empty($versions))
|
||||||
if ($highest_version->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS)
|
|
||||||
{
|
{
|
||||||
$highest_version = $highest_version->getAliasOf();
|
$highest_version = $versions[0];
|
||||||
|
|
||||||
|
// If highest version is a non-numeric dev branch, it's an instance of CompleteAliasPackage,
|
||||||
|
// so we need to get the package being aliased in order to show the true non-numeric version.
|
||||||
|
if ($highest_version instanceof CompleteAliasPackage)
|
||||||
|
{
|
||||||
|
$highest_version = $highest_version->getAliasOf();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generates the entry
|
// Generates the entry
|
||||||
|
|
Loading…
Add table
Reference in a new issue