Skip to content

Commit

Permalink
Avoid Perl error in 'Elevate::Components::Repositories'
Browse files Browse the repository at this point in the history
Case RE-964: This change adds a better guard in
'Elevate::Components::Repositories::_autofix_duplicate_repoids'. It also
initializes '$self->{__duplicate_repoids} as a href instead of an aref.

Changelog: Avoid Perl error in 'Elevate::Components::Repositories'
  • Loading branch information
Travis Holloway committed Nov 15, 2024
1 parent f938c04 commit 8796189
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion elevate-cpanel
Original file line number Diff line number Diff line change
Expand Up @@ -5585,7 +5585,7 @@ EOS
$self->{_yum_repos_path_using_invalid_syntax} = [];
$self->{_yum_repos_to_disable} = [];
$self->{_yum_repos_unsupported_with_packages} = [];
$self->{_duplicate_repoids} = [];
$self->{_duplicate_repoids} = {};

my @vetted_repos = Elevate::OS::vetted_yum_repo();

Expand Down Expand Up @@ -5713,6 +5713,7 @@ EOS
}

sub _autofix_duplicate_repoids ($self) {
return unless ref $self->{_duplicate_repoids} && ref $self->{_duplicate_repoids} eq 'HASH';
my %duplicate_ids = $self->{_duplicate_repoids}->%*;
foreach my $id ( keys %duplicate_ids ) {
if ( $id =~ m/^MariaDB[0-9]+/ ) {
Expand Down
3 changes: 2 additions & 1 deletion lib/Elevate/Components/Repositories.pm
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ sub _check_yum_repos ($self) {
$self->{_yum_repos_path_using_invalid_syntax} = [];
$self->{_yum_repos_to_disable} = [];
$self->{_yum_repos_unsupported_with_packages} = [];
$self->{_duplicate_repoids} = [];
$self->{_duplicate_repoids} = {};

my @vetted_repos = Elevate::OS::vetted_yum_repo();

Expand Down Expand Up @@ -458,6 +458,7 @@ sub _check_yum_repos ($self) {
}

sub _autofix_duplicate_repoids ($self) {
return unless ref $self->{_duplicate_repoids} && ref $self->{_duplicate_repoids} eq 'HASH';
my %duplicate_ids = $self->{_duplicate_repoids}->%*;
foreach my $id ( keys %duplicate_ids ) {
if ( $id =~ m/^MariaDB[0-9]+/ ) {
Expand Down

0 comments on commit 8796189

Please sign in to comment.