Skip to content

Commit 2b70836

Browse files
authored
Fix: Do not pass null to function that expects DateTime or string (#869)
1 parent 019de1f commit 2b70836

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

eol.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<?php foreach (get_eol_branches() as $major => $branches): ?>
4949
<?php foreach ($branches as $branch => $detail): ?>
5050
<?php $eolDate = get_branch_security_eol_date($branch) ?>
51-
<?php $eolPeriod = format_interval($eolDate, null) ?>
51+
<?php $eolPeriod = format_interval($eolDate, new DateTime('now')) ?>
5252
<tr>
5353
<td><?php echo htmlspecialchars($branch); ?></td>
5454
<td>

include/branches.inc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ $BRANCHES = [
4343
* page. (Currently 28 days.) */
4444
$KEEP_EOL = new DateInterval('P28D');
4545

46-
function format_interval($from, $to) {
46+
function format_interval($from, DateTime $to) {
4747
try {
4848
$from_obj = $from instanceof DateTime ? $from : new DateTime($from);
49-
$to_obj = $to instanceof DateTime ? $to : new DateTime($to);
50-
$diff = $to_obj->diff($from_obj);
49+
$diff = $to->diff($from_obj);
5150

5251
$times = [];
5352
if ($diff->y) {

supported-versions.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
$initial = get_branch_release_date($branch);
5555
$until = get_branch_bug_eol_date($branch);
5656
$eol = get_branch_security_eol_date($branch);
57+
$now = new DateTime('now');
5758
?>
5859
<tr class="<?php echo $state ?>">
5960
<td>
@@ -63,11 +64,11 @@
6364
<?php endif ?>
6465
</td>
6566
<td><?php echo htmlspecialchars($initial->format('j M Y')) ?></td>
66-
<td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($initial, null)) ?></em></td>
67+
<td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($initial, $now)) ?></em></td>
6768
<td><?php echo htmlspecialchars($until->format('j M Y')) ?></td>
68-
<td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($until, null)) ?></em></td>
69+
<td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($until, $now)) ?></em></td>
6970
<td><?php echo htmlspecialchars($eol->format('j M Y')) ?></td>
70-
<td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($eol, null)) ?></em></td>
71+
<td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($eol, $now)) ?></em></td>
7172
</tr>
7273
<?php endforeach ?>
7374
<?php endforeach ?>

0 commit comments

Comments
 (0)