Fix to return a new list instead

This commit is contained in:
Ilia Ross 2025-05-26 01:21:01 +03:00
parent 52e24d98e2
commit 92dc310ce0
No known key found for this signature in database
GPG Key ID: 121E166DD9C821AB
2 changed files with 17 additions and 12 deletions

View File

@ -58,12 +58,11 @@ if (&foreign_installed("package-updates")) {
print &ui_form_start(
&get_webprefix()."/package-updates/update.cgi", "post");
print "$text{'pkgs_newver'} \n";
&extend_installable_php_packages(\@newpkgs);
# Largest version on top
@newpkgs = sort { $b->{'phpver'} cmp $a->{'phpver'} } @newpkgs;
my @allpkgs = &extend_installable_php_packages(\@newpkgs);
@allpkgs = sort { $b->{'ver'} cmp $a->{'ver'} } @allpkgs;
print &ui_select("u", undef,
[ map { [ $_->{'name'},
"PHP $_->{'shortver'}" ] } @newpkgs ]);
"PHP $_->{'ver'}" ] } @allpkgs ]);
print &ui_hidden(
"redir", &get_webprefix()."/$module_name/list_pkgs.cgi");
print &ui_hidden("redirdesc", $text{'pkgs_title'});

View File

@ -1034,21 +1034,27 @@ return @rv;
}
# extend_installable_php_packages(&packages)
# Given a list of PHP packages to install, extends them to include packages
# that are also has to be installed, such as -cli or -fpm
# Given a list of PHP packages to install, create a new list with the version
# and name to include packages that also need to be installed, such as -cli or
# -fpm.
sub extend_installable_php_packages
{
my ($pkgs) = @_;
my @pkgs;
my @extra = ('cli', 'fpm');
foreach my $pkg (@$pkgs) {
if ($pkg->{'name'} =~ /-common$/) {
$pkg->{'name'} .= ' ' . join(' ',
foreach my $pkg (@{$pkgs}) {
my $p = { 'name' => $pkg->{'name'},
'ver' => $pkg->{'shortver'} };
if ($p->{'name'} =~ /-common$/) {
$p->{'name'} .= ' ' . join(' ',
map {
my $n = $pkg->{'name'};
$n =~ s/-common$/-$_/;
$n } @extra);
my $n = $p->{'name'};
$n =~ s/-common$/-$_/;
$n } @extra);
}
push(@pkgs, $p);
}
return @pkgs;
}
# delete_php_base_package(&package, &installed)