From 8796189b376c6b14353222d9a2146217b875b4c7 Mon Sep 17 00:00:00 2001 From: Travis Holloway Date: Fri, 15 Nov 2024 13:31:49 -0600 Subject: [PATCH] Avoid Perl error in 'Elevate::Components::Repositories' 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' --- elevate-cpanel | 3 ++- lib/Elevate/Components/Repositories.pm | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/elevate-cpanel b/elevate-cpanel index db38b62e..a92ec9b2 100755 --- a/elevate-cpanel +++ b/elevate-cpanel @@ -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(); @@ -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]+/ ) { diff --git a/lib/Elevate/Components/Repositories.pm b/lib/Elevate/Components/Repositories.pm index 71d856bd..7ec73275 100644 --- a/lib/Elevate/Components/Repositories.pm +++ b/lib/Elevate/Components/Repositories.pm @@ -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(); @@ -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]+/ ) {