Commit:    695ec0732d777515dddf2788fd0569fd370f0725
Author:    Adam Harvey <[email protected]>         Wed, 20 Jul 2016 19:20:58 -0700
Parents:   f02b126d48495cb63050c7424e20970c178386f4
Branches:  master

Link:       
http://git.php.net/?p=web/php.git;a=commitdiff;h=695ec0732d777515dddf2788fd0569fd370f0725

Log:
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.

Changed paths:
  M  eol.php
  M  include/branches.inc
  M  include/version.inc


Diff:
diff --git a/eol.php b/eol.php
index 84f05ea..d3446f9 100644
--- a/eol.php
+++ b/eol.php
@@ -40,11 +40,12 @@ site_header('Unsupported Branches');
        <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>
diff --git a/include/branches.inc b/include/branches.inc
index dce3eb0..c548726 100644
--- a/include/branches.inc
+++ b/include/branches.inc
@@ -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',
@@ -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);
@@ -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;
                                }
@@ -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) {
@@ -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]);
@@ -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']);
@@ -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;
 }
 
diff --git a/include/version.inc b/include/version.inc
index 22989c9..5e34a28 100644
--- a/include/version.inc
+++ b/include/version.inc
@@ -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)"
  *         ),
  *     ),
  * );


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to