Skip to content

Commit

Permalink
Merge pull request #357 from timmullin/Issue-339
Browse files Browse the repository at this point in the history
Provide expected version when cPanel version is not up to date.
  • Loading branch information
toddr authored Jan 23, 2024
2 parents f20c08b + 6ec2258 commit 045149e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
9 changes: 4 additions & 5 deletions elevate-cpanel
Original file line number Diff line number Diff line change
Expand Up @@ -2026,13 +2026,12 @@ EOS

sub _blocker_cpanel_needs_update ($self) {
if ( !$self->getopt('skip-cpanel-version-check') ) {
my $tiers_obj = Cpanel::Update::Tiers->new( logger => Log::Log4perl->get_logger(__PACKAGE__) );
if ( !grep { Cpanel::Version::Compare::compare( $Cpanel::Version::Tiny::VERSION_BUILD, '==', $_ ) } $tiers_obj->get_flattened_hash()->@{qw/edge current release stable lts/} ) {
my $hint = '';
$hint = q[hint: You can skip this check using --skip-cpanel-version-check] if $Cpanel::Version::Tiny::VERSION_BUILD =~ 9999;
my $tiers_obj = Cpanel::Update::Tiers->new( logger => Log::Log4perl->get_logger(__PACKAGE__) );
my $expected_version = $tiers_obj->get_flattened_hash()->{'11.110'};
if ( !Cpanel::Version::Compare::compare( $Cpanel::Version::Tiny::VERSION_BUILD, '==', $expected_version ) ) {
return $self->has_blocker( <<~"EOS" );
This installation of cPanel ($Cpanel::Version::Tiny::VERSION_BUILD) does not appear to be up to date.
Please upgrade cPanel to a more recent version. $hint
Please upgrade cPanel to $expected_version.
EOS
}
}
Expand Down
9 changes: 4 additions & 5 deletions lib/Elevate/Blockers/WHM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,12 @@ sub _blocker_cpanel_needs_license ($self) {

sub _blocker_cpanel_needs_update ($self) {
if ( !$self->getopt('skip-cpanel-version-check') ) {
my $tiers_obj = Cpanel::Update::Tiers->new( logger => Log::Log4perl->get_logger(__PACKAGE__) );
if ( !grep { Cpanel::Version::Compare::compare( $Cpanel::Version::Tiny::VERSION_BUILD, '==', $_ ) } $tiers_obj->get_flattened_hash()->@{qw/edge current release stable lts/} ) {
my $hint = '';
$hint = q[hint: You can skip this check using --skip-cpanel-version-check] if $Cpanel::Version::Tiny::VERSION_BUILD =~ 9999;
my $tiers_obj = Cpanel::Update::Tiers->new( logger => Log::Log4perl->get_logger(__PACKAGE__) );
my $expected_version = $tiers_obj->get_flattened_hash()->{'11.110'};
if ( !Cpanel::Version::Compare::compare( $Cpanel::Version::Tiny::VERSION_BUILD, '==', $expected_version ) ) {
return $self->has_blocker( <<~"EOS" );
This installation of cPanel ($Cpanel::Version::Tiny::VERSION_BUILD) does not appear to be up to date.
Please upgrade cPanel to a more recent version. $hint
Please upgrade cPanel to $expected_version.
EOS
}
}
Expand Down
13 changes: 11 additions & 2 deletions t/blocker-whm.t
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ my $whm = $cpev->get_blocker('WHM');
note "cPanel & WHM latest version.";
clear_messages_seen();

my $latest_lts_version = "11.110.0.15";

my $mock_tiers = Test::MockModule->new('Cpanel::Update::Tiers');
$mock_tiers->redefine(
sync_tiers_file => 1,
Expand All @@ -169,6 +171,13 @@ my $whm = $cpev->get_blocker('WHM');
"named" => [ "current", "edge" ],
}
],
"11.110" => [
{
"build" => $latest_lts_version,
"is_main" => 1,
"named" => [ "lts" ],
}
],
},
},
);
Expand All @@ -195,15 +204,15 @@ my $whm = $cpev->get_blocker('WHM');
msg => qr{
\QThis installation of cPanel (11.102.0.5) does not appear to be up to date.\E
\s+
\QPlease upgrade cPanel to a more recent version.\E
\QPlease upgrade cPanel to $latest_lts_version.\E
}xms,
},
q{obsolete version generates a blocker.}
);

clear_messages_seen();

$Cpanel::Version::Tiny::VERSION_BUILD = '11.102.0.7';
$Cpanel::Version::Tiny::VERSION_BUILD = $latest_lts_version;
is( $whm->_blocker_cpanel_needs_update(), 0, "No blocker if cPanel is up to date" );
no_messages_seen();
}
Expand Down

0 comments on commit 045149e

Please sign in to comment.