@@ -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+
3142function 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
114125function 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() {
136148function 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+
229273function 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
0 commit comments