Skip to content

Commit

Permalink
Bug 1852154: Warn admin if end-of-support date is approaching (#135)
Browse files Browse the repository at this point in the history
* Also restores the update-check output on the home page, apparently BMO had removed it.
a=dylan
  • Loading branch information
justdave authored Aug 26, 2024
1 parent 39cddb6 commit b16e1e5
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 1 deletion.
44 changes: 43 additions & 1 deletion Bugzilla/Update.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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') {
Expand All @@ -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') {
Expand Down
51 changes: 51 additions & 0 deletions template/en/default/index.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,57 @@
no_yui = 1
%]

[% IF release %]
<div id="new_release">
[% IF release.data %]
[% IF release.eos_date %]
<p>[% 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.</p>
[% END %]
[% IF release.deprecated %]
<p>Bugzilla [%+ release.deprecated FILTER html %] is no longer
supported. You are highly encouraged to upgrade in order to keep your
system secure.</p>
[% END %]

<p>A new Bugzilla version ([% release.data.latest_ver FILTER html %])
is available at
<a href="[% release.data.url FILTER html %]">[% release.data.url FILTER html %]</a>.<br>
Release date: [% release.data.date FILTER html %]</p>

<p class="notice">This message is only shown to logged in users with admin privs.
You can configure this notification from the
<a href="editparams.cgi?section=general#upgrade_notification_desc">Parameters</a> page.</p>
[% ELSIF release.error == "cannot_download" %]
<p>The remote file <a href="[% constants.REMOTE_FILE FILTER html %]">
[%~ constants.REMOTE_FILE FILTER html %]</a> cannot be downloaded
(reason: [% release.reason FILTER html %]).<br>
Either the remote server is temporarily unavailable, or your web server cannot access
the web. If you are behind a proxy, set the
<a href="editparams.cgi?section=advanced#proxy_url_desc">proxy_url</a> parameter correctly.</p>
[% ELSIF release.error == "no_write" %]
<p>The local XML file '[% constants.LOCAL_FILE FILTER html %]' cannot be created
(reason: [% release.reason FILTER html %]).<br>
Please make sure the web server can write into this directory.
[% ELSIF release.error == "no_update" %]
<p>The local XML file '[% constants.LOCAL_FILE FILTER html %]' cannot be updated.
Please make sure the web server can edit this file.</p>
[% ELSIF release.error == "no_access" %]
<p>The local XML file '[% constants.LOCAL_FILE FILTER html %]' cannot be read.
Please make sure this file has the correct rights set on it.</p>
[% ELSIF release.error == "corrupted" %]
<p>The local XML file '[% constants.LOCAL_FILE FILTER html %]' has an invalid XML format.
Please delete it and try accessing this page again.</p>
[% ELSIF release.error == "unknown_parameter" %]
<p>'[% Param("upgrade_notification") FILTER html %]' is not a valid notification
parameter. Please check this parameter in the
<a href="editparams.cgi?section=general#upgrade_notification_desc">Parameters</a> page.</p>
[% END %]
</div>
[% END %]

<div id="page-index">
<table>
<tr>
Expand Down

0 comments on commit b16e1e5

Please sign in to comment.