From b16e1e5bfd241c8cfcdce7d5f755431394b29d2f Mon Sep 17 00:00:00 2001 From: Dave Miller Date: Sun, 25 Aug 2024 21:25:10 -0400 Subject: [PATCH] Bug 1852154: Warn admin if end-of-support date is approaching (#135) * Also restores the update-check output on the home page, apparently BMO had removed it. a=dylan --- Bugzilla/Update.pm | 44 ++++++++++++++++++++++++- template/en/default/index.html.tmpl | 51 +++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/Bugzilla/Update.pm b/Bugzilla/Update.pm index 9f92881622..775eb67143 100644 --- a/Bugzilla/Update.pm +++ b/Bugzilla/Update.pm @@ -52,7 +52,8 @@ sub get_notifications { 'latest_ver' => $branch->{'att'}->{'vid'}, 'status' => $branch->{'att'}->{'status'}, 'url' => $branch->{'att'}->{'url'}, - 'date' => $branch->{'att'}->{'date'} + 'date' => $branch->{'att'}->{'date'}, + 'eos_date' => exists($branch->{'att'}->{'eos-date'}) ? $branch->{'att'}->{'eos-date'} : undef, }; push(@releases, $release); } @@ -72,6 +73,35 @@ sub get_notifications { } } elsif (Bugzilla->params->{'upgrade_notification'} eq 'latest_stable_release') { + # We want the latest stable version for the current branch. + # If we are running a development snapshot, we won't match anything. + my $branch_version = $current_version[0] . '.' . $current_version[1]; + + # We do a string comparison instead of a numerical one, because + # e.g. 2.2 == 2.20, but 2.2 ne 2.20 (and 2.2 is indeed much older). + @release = grep { $_->{'branch_ver'} eq $branch_version } @releases; + + # If the branch has an end-of-support date listed, we should + # strongly suggest to upgrade to the latest stable release + # available. + if (scalar(@release) && $release[0]->{'status'} ne 'closed' + && defined($release[0]->{'eos_date'})) { + my $eos_date = $release[0]->{'eos_date'}; + @release = grep {$_->{'status'} eq 'stable'} @releases; + return {'data' => $release[0], + 'branch_version' => $branch_version, + 'eos_date' => $eos_date} + }; + + # If the branch is now closed, we should strongly suggest + # to upgrade to the latest stable release available. + if (scalar(@release) && $release[0]->{'status'} eq 'closed') { + @release = grep { $_->{'status'} eq 'stable' } @releases; + return {'data' => $release[0], 'deprecated' => $branch_version}; + } + + # If we get here, then we want to recommend the lastest stable + # release without any other messages. @release = grep { $_->{'status'} eq 'stable' } @releases; } elsif (Bugzilla->params->{'upgrade_notification'} eq 'stable_branch_release') { @@ -84,6 +114,18 @@ sub get_notifications { # e.g. 2.2 == 2.20, but 2.2 ne 2.20 (and 2.2 is indeed much older). @release = grep { $_->{'branch_ver'} eq $branch_version } @releases; + # If the branch has an end-of-support date listed, we should + # strongly suggest to upgrade to the latest stable release + # available. + if (scalar(@release) && $release[0]->{'status'} ne 'closed' + && defined($release[0]->{'eos_date'})) { + my $eos_date = $release[0]->{'eos_date'}; + @release = grep {$_->{'status'} eq 'stable'} @releases; + return {'data' => $release[0], + 'branch_version' => $branch_version, + 'eos_date' => $eos_date} + }; + # If the branch is now closed, we should strongly suggest # to upgrade to the latest stable release available. if (scalar(@release) && $release[0]->{'status'} eq 'closed') { diff --git a/template/en/default/index.html.tmpl b/template/en/default/index.html.tmpl index c4f0af2d4f..5e7098dc76 100644 --- a/template/en/default/index.html.tmpl +++ b/template/en/default/index.html.tmpl @@ -32,6 +32,57 @@ no_yui = 1 %] +[% IF release %] +
+ [% IF release.data %] + [% IF release.eos_date %] +

[% terms.Bugzilla %] [%+ release.branch_version FILTER html %] will + no longer receive security updates after [% release.eos_date FILTER html %]. + You are highly encouraged to upgrade in order to keep your + system secure.

+ [% END %] + [% IF release.deprecated %] +

Bugzilla [%+ release.deprecated FILTER html %] is no longer + supported. You are highly encouraged to upgrade in order to keep your + system secure.

+ [% END %] + +

A new Bugzilla version ([% release.data.latest_ver FILTER html %]) + is available at + [% release.data.url FILTER html %].
+ Release date: [% release.data.date FILTER html %]

+ +

This message is only shown to logged in users with admin privs. + You can configure this notification from the + Parameters page.

+ [% ELSIF release.error == "cannot_download" %] +

The remote file + [%~ constants.REMOTE_FILE FILTER html %] cannot be downloaded + (reason: [% release.reason FILTER html %]).
+ Either the remote server is temporarily unavailable, or your web server cannot access + the web. If you are behind a proxy, set the + proxy_url parameter correctly.

+ [% ELSIF release.error == "no_write" %] +

The local XML file '[% constants.LOCAL_FILE FILTER html %]' cannot be created + (reason: [% release.reason FILTER html %]).
+ Please make sure the web server can write into this directory. + [% ELSIF release.error == "no_update" %] +

The local XML file '[% constants.LOCAL_FILE FILTER html %]' cannot be updated. + Please make sure the web server can edit this file.

+ [% ELSIF release.error == "no_access" %] +

The local XML file '[% constants.LOCAL_FILE FILTER html %]' cannot be read. + Please make sure this file has the correct rights set on it.

+ [% ELSIF release.error == "corrupted" %] +

The local XML file '[% constants.LOCAL_FILE FILTER html %]' has an invalid XML format. + Please delete it and try accessing this page again.

+ [% ELSIF release.error == "unknown_parameter" %] +

'[% Param("upgrade_notification") FILTER html %]' is not a valid notification + parameter. Please check this parameter in the + Parameters page.

+ [% END %] +
+[% END %] +