Skip to content

Commit 695ec07

Browse files
committed
Remove the "eol" hackery that I added a couple of years ago.
For "modern" PHP branches (5.3 onwards), we'll base whether they're considered active purely off the support dates for the branch. To ensure that we don't immediately remove the download links for EOL branches from the front page, we'll still consider them "active" for those purposes for 28 days after the final release. Basically, rather than having two sources of truth for whether a branch is EOL or not (the flag and the support dates in branches.inc), we now have one (the support dates). This should be an improvement.
1 parent f02b126 commit 695ec07

File tree

3 files changed

+57
-6
lines changed

3 files changed

+57
-6
lines changed

eol.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@
4040
<tbody>
4141
<?php foreach (get_eol_branches() as $major => $branches): ?>
4242
<?php foreach ($branches as $branch => $detail): ?>
43-
<?php $eolPeriod = format_interval('@'.$detail['date'], null) ?>
43+
<?php $eolDate = get_branch_security_eol_date($branch) ?>
44+
<?php $eolPeriod = format_interval($eolDate, null) ?>
4445
<tr>
4546
<td><?php echo htmlspecialchars($branch); ?></td>
4647
<td>
47-
<?php echo date('j M Y', $detail['date']); ?>
48+
<?php echo $eolDate->format('j M Y') ?>
4849
</td>
4950
<td>
5051
<em><?php echo $eolPeriod ?></em>

include/branches.inc

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ include_once $_SERVER['DOCUMENT_ROOT'] . '/include/version.inc';
1010
* - security: the end of security support (usually release + 3 years).
1111
*/
1212
$BRANCHES = array(
13+
/* 3.0 is here because version_compare() can't handle the only version in
14+
* $OLDRELEASES, and it saves another special case in
15+
* get_branch_security_eol_date(). */
16+
'3.0' => array(
17+
'security' => '2000-10-20',
18+
),
1319
'5.3' => array(
1420
'stable' => '2013-07-11',
1521
'security' => '2014-08-14',
@@ -28,6 +34,11 @@ $BRANCHES = array(
2834
),
2935
);
3036

37+
/* Time to keep EOLed branches in the array returned by get_active_branches(),
38+
* which is used on the front page download links and the supported versions
39+
* page. (Currently 28 days.) */
40+
$KEEP_EOL = new DateInterval('P28D');
41+
3142
function format_interval($from, $to) {
3243
try {
3344
$from_obj = $from instanceof DateTime ? $from : new DateTime($from);
@@ -113,11 +124,12 @@ function get_all_branches() {
113124

114125
function get_active_branches() {
115126
$branches = array();
127+
$now = new DateTime;
116128

117129
foreach ($GLOBALS['RELEASES'] as $major => $releases) {
118130
foreach ($releases as $version => $release) {
119131
if ($branch = version_number_to_branch($version)) {
120-
if (empty($release['eol'])) {
132+
if ($now < get_branch_security_eol_date($branch)->add($GLOBALS['KEEP_EOL'])) {
121133
$branches[$major][$branch] = $release;
122134
$branches[$major][$branch]['version'] = $version;
123135
}
@@ -136,6 +148,7 @@ function get_active_branches() {
136148
function get_eol_branches($always_include = null) {
137149
$always_include = $always_include ? $always_include : array();
138150
$branches = array();
151+
$now = new DateTime;
139152

140153
// Gather the last release on each branch into a convenient array.
141154
foreach ($GLOBALS['OLDRELEASES'] as $major => $releases) {
@@ -157,7 +170,7 @@ function get_eol_branches($always_include = null) {
157170
foreach ($GLOBALS['RELEASES'] as $major => $releases) {
158171
foreach ($releases as $version => $release) {
159172
if ($branch = version_number_to_branch($version)) {
160-
if (empty($release['eol'])) {
173+
if ($now < get_branch_security_eol_date($branch)) {
161174
/* This branch isn't EOL: remove it from our array. */
162175
if (isset($branches[$major][$branch])) {
163176
unset($branches[$major][$branch]);
@@ -226,6 +239,37 @@ function get_initial_release($branch) {
226239
return null;
227240
}
228241

242+
function get_final_release($branch) {
243+
$branch = version_number_to_branch($branch);
244+
if (!$branch) {
245+
return null;
246+
}
247+
$major = substr($branch, 0, strpos($branch, '.'));
248+
249+
$last = "$branch.0";
250+
foreach ($GLOBALS['OLDRELEASES'][$major] as $version => $release) {
251+
if (version_number_to_branch($version) == $branch && version_compare($version, $last, '>')) {
252+
$last = $version;
253+
}
254+
}
255+
256+
if (isset($GLOBALS['OLDRELEASES'][$major][$last])) {
257+
return $GLOBALS['OLDRELEASES'][$major][$last];
258+
}
259+
260+
/* If there's only been one release on the branch, it won't be in
261+
* $OLDRELEASES yet, so let's check $RELEASES. */
262+
if (isset($GLOBALS['RELEASES'][$major][$last])) {
263+
// Fake a date like we have on the oldreleases array.
264+
$release = $GLOBALS['RELEASES'][$major][$last];
265+
$release['date'] = $release['source'][0]['date'];
266+
return $release;
267+
}
268+
269+
// Shrug.
270+
return null;
271+
}
272+
229273
function get_branch_bug_eol_date($branch) {
230274
if (isset($GLOBALS['BRANCHES'][$branch]['stable'])) {
231275
return new DateTime($GLOBALS['BRANCHES'][$branch]['stable']);
@@ -241,8 +285,15 @@ function get_branch_security_eol_date($branch) {
241285
return new DateTime($GLOBALS['BRANCHES'][$branch]['security']);
242286
}
243287

244-
$date = get_branch_release_date($branch);
288+
/* Versions before 5.3 are based solely on the final release date in
289+
* $OLDRELEASES. */
290+
if (version_compare($branch, '5.3', '<')) {
291+
$release = get_final_release($branch);
245292

293+
return $release ? new DateTime($release['date']) : null;
294+
}
295+
296+
$date = get_branch_release_date($branch);
246297
return $date ? $date->add(new DateInterval('P3Y')) : null;
247298
}
248299

include/version.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* "note" => "this file was updated 29feb due to broken phar files..",
1313
* ),
1414
* "announcement" => "bool, release announcement exists in releases/?",
15-
* "eol" => "bool, true to mark as EOL (affects bug tracker and eol.php)"
1615
* ),
1716
* ),
1817
* );

0 commit comments

Comments
 (0)