@@ -10,6 +10,12 @@ include_once $_SERVER['DOCUMENT_ROOT'] . '/include/version.inc';
10
10
* - security: the end of security support (usually release + 3 years).
11
11
*/
12
12
$ 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
+ ),
13
19
'5.3 ' => array (
14
20
'stable ' => '2013-07-11 ' ,
15
21
'security ' => '2014-08-14 ' ,
@@ -28,6 +34,11 @@ $BRANCHES = array(
28
34
),
29
35
);
30
36
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
+
31
42
function format_interval ($ from , $ to ) {
32
43
try {
33
44
$ from_obj = $ from instanceof DateTime ? $ from : new DateTime ($ from );
@@ -113,11 +124,12 @@ function get_all_branches() {
113
124
114
125
function get_active_branches () {
115
126
$ branches = array ();
127
+ $ now = new DateTime ;
116
128
117
129
foreach ($ GLOBALS ['RELEASES ' ] as $ major => $ releases ) {
118
130
foreach ($ releases as $ version => $ release ) {
119
131
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 ' ])) {
121
133
$ branches [$ major ][$ branch ] = $ release ;
122
134
$ branches [$ major ][$ branch ]['version ' ] = $ version ;
123
135
}
@@ -136,6 +148,7 @@ function get_active_branches() {
136
148
function get_eol_branches ($ always_include = null ) {
137
149
$ always_include = $ always_include ? $ always_include : array ();
138
150
$ branches = array ();
151
+ $ now = new DateTime ;
139
152
140
153
// Gather the last release on each branch into a convenient array.
141
154
foreach ($ GLOBALS ['OLDRELEASES ' ] as $ major => $ releases ) {
@@ -157,7 +170,7 @@ function get_eol_branches($always_include = null) {
157
170
foreach ($ GLOBALS ['RELEASES ' ] as $ major => $ releases ) {
158
171
foreach ($ releases as $ version => $ release ) {
159
172
if ($ branch = version_number_to_branch ($ version )) {
160
- if (empty ( $ release [ ' eol ' ] )) {
173
+ if ($ now < get_branch_security_eol_date ( $ branch )) {
161
174
/* This branch isn't EOL: remove it from our array. */
162
175
if (isset ($ branches [$ major ][$ branch ])) {
163
176
unset($ branches [$ major ][$ branch ]);
@@ -226,6 +239,37 @@ function get_initial_release($branch) {
226
239
return null ;
227
240
}
228
241
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
+
229
273
function get_branch_bug_eol_date ($ branch ) {
230
274
if (isset ($ GLOBALS ['BRANCHES ' ][$ branch ]['stable ' ])) {
231
275
return new DateTime ($ GLOBALS ['BRANCHES ' ][$ branch ]['stable ' ]);
@@ -241,8 +285,15 @@ function get_branch_security_eol_date($branch) {
241
285
return new DateTime ($ GLOBALS ['BRANCHES ' ][$ branch ]['security ' ]);
242
286
}
243
287
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 );
245
292
293
+ return $ release ? new DateTime ($ release ['date ' ]) : null ;
294
+ }
295
+
296
+ $ date = get_branch_release_date ($ branch );
246
297
return $ date ? $ date ->add (new DateInterval ('P3Y ' )) : null ;
247
298
}
248
299
0 commit comments