Skip to content

Commit

Permalink
Remove the "eol" hackery that I added a couple of years ago.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LawnGnome committed Jul 21, 2016
1 parent f02b126 commit 695ec07
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
5 changes: 3 additions & 2 deletions eol.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@
<tbody>
<?php foreach (get_eol_branches() as $major => $branches): ?>
<?php foreach ($branches as $branch => $detail): ?>
<?php $eolPeriod = format_interval('@'.$detail['date'], null) ?>
<?php $eolDate = get_branch_security_eol_date($branch) ?>
<?php $eolPeriod = format_interval($eolDate, null) ?>
<tr>
<td><?php echo htmlspecialchars($branch); ?></td>
<td>
<?php echo date('j M Y', $detail['date']); ?>
<?php echo $eolDate->format('j M Y') ?>
</td>
<td>
<em><?php echo $eolPeriod ?></em>
Expand Down
57 changes: 54 additions & 3 deletions include/branches.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ include_once $_SERVER['DOCUMENT_ROOT'] . '/include/version.inc';
* - security: the end of security support (usually release + 3 years).
*/
$BRANCHES = array(
/* 3.0 is here because version_compare() can't handle the only version in
* $OLDRELEASES, and it saves another special case in
* get_branch_security_eol_date(). */
'3.0' => array(
'security' => '2000-10-20',
),
'5.3' => array(
'stable' => '2013-07-11',
'security' => '2014-08-14',
Expand All @@ -28,6 +34,11 @@ $BRANCHES = array(
),
);

/* Time to keep EOLed branches in the array returned by get_active_branches(),
* which is used on the front page download links and the supported versions
* page. (Currently 28 days.) */
$KEEP_EOL = new DateInterval('P28D');

function format_interval($from, $to) {
try {
$from_obj = $from instanceof DateTime ? $from : new DateTime($from);
Expand Down Expand Up @@ -113,11 +124,12 @@ function get_all_branches() {

function get_active_branches() {
$branches = array();
$now = new DateTime;

foreach ($GLOBALS['RELEASES'] as $major => $releases) {
foreach ($releases as $version => $release) {
if ($branch = version_number_to_branch($version)) {
if (empty($release['eol'])) {
if ($now < get_branch_security_eol_date($branch)->add($GLOBALS['KEEP_EOL'])) {
$branches[$major][$branch] = $release;
$branches[$major][$branch]['version'] = $version;
}
Expand All @@ -136,6 +148,7 @@ function get_active_branches() {
function get_eol_branches($always_include = null) {
$always_include = $always_include ? $always_include : array();
$branches = array();
$now = new DateTime;

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

function get_final_release($branch) {
$branch = version_number_to_branch($branch);
if (!$branch) {
return null;
}
$major = substr($branch, 0, strpos($branch, '.'));

$last = "$branch.0";
foreach ($GLOBALS['OLDRELEASES'][$major] as $version => $release) {
if (version_number_to_branch($version) == $branch && version_compare($version, $last, '>')) {
$last = $version;
}
}

if (isset($GLOBALS['OLDRELEASES'][$major][$last])) {
return $GLOBALS['OLDRELEASES'][$major][$last];
}

/* If there's only been one release on the branch, it won't be in
* $OLDRELEASES yet, so let's check $RELEASES. */
if (isset($GLOBALS['RELEASES'][$major][$last])) {
// Fake a date like we have on the oldreleases array.
$release = $GLOBALS['RELEASES'][$major][$last];
$release['date'] = $release['source'][0]['date'];
return $release;
}

// Shrug.
return null;
}

function get_branch_bug_eol_date($branch) {
if (isset($GLOBALS['BRANCHES'][$branch]['stable'])) {
return new DateTime($GLOBALS['BRANCHES'][$branch]['stable']);
Expand All @@ -241,8 +285,15 @@ function get_branch_security_eol_date($branch) {
return new DateTime($GLOBALS['BRANCHES'][$branch]['security']);
}

$date = get_branch_release_date($branch);
/* Versions before 5.3 are based solely on the final release date in
* $OLDRELEASES. */
if (version_compare($branch, '5.3', '<')) {
$release = get_final_release($branch);

return $release ? new DateTime($release['date']) : null;
}

$date = get_branch_release_date($branch);
return $date ? $date->add(new DateInterval('P3Y')) : null;
}

Expand Down
1 change: 0 additions & 1 deletion include/version.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* "note" => "this file was updated 29feb due to broken phar files..",
* ),
* "announcement" => "bool, release announcement exists in releases/?",
* "eol" => "bool, true to mark as EOL (affects bug tracker and eol.php)"
* ),
* ),
* );
Expand Down

0 comments on commit 695ec07

Please sign in to comment.