Author: Andreas Möller (localheinz) Committer: GitHub (web-flow) Pusher: kamil-tekiela Date: 2023-12-06T17:47:00+01:00
Commit: https://github.com/php/web-php/commit/2b708363b55739b32ae59ccccc62a7ad2fb1b462 Raw diff: https://github.com/php/web-php/commit/2b708363b55739b32ae59ccccc62a7ad2fb1b462.diff Fix: Do not pass null to function that expects DateTime or string (#869) Changed paths: M eol.php M include/branches.inc M supported-versions.php Diff: diff --git a/eol.php b/eol.php index 4025663660..6685606aa2 100644 --- a/eol.php +++ b/eol.php @@ -48,7 +48,7 @@ <?php foreach (get_eol_branches() as $major => $branches): ?> <?php foreach ($branches as $branch => $detail): ?> <?php $eolDate = get_branch_security_eol_date($branch) ?> - <?php $eolPeriod = format_interval($eolDate, null) ?> + <?php $eolPeriod = format_interval($eolDate, new DateTime('now')) ?> <tr> <td><?php echo htmlspecialchars($branch); ?></td> <td> diff --git a/include/branches.inc b/include/branches.inc index 44d6f987a2..f31ab8567b 100644 --- a/include/branches.inc +++ b/include/branches.inc @@ -43,11 +43,10 @@ $BRANCHES = [ * page. (Currently 28 days.) */ $KEEP_EOL = new DateInterval('P28D'); -function format_interval($from, $to) { +function format_interval($from, DateTime $to) { try { $from_obj = $from instanceof DateTime ? $from : new DateTime($from); - $to_obj = $to instanceof DateTime ? $to : new DateTime($to); - $diff = $to_obj->diff($from_obj); + $diff = $to->diff($from_obj); $times = []; if ($diff->y) { diff --git a/supported-versions.php b/supported-versions.php index 36bb92751d..a6c6ffe9e7 100644 --- a/supported-versions.php +++ b/supported-versions.php @@ -54,6 +54,7 @@ $initial = get_branch_release_date($branch); $until = get_branch_bug_eol_date($branch); $eol = get_branch_security_eol_date($branch); + $now = new DateTime('now'); ?> <tr class="<?php echo $state ?>"> <td> @@ -63,11 +64,11 @@ <?php endif ?> </td> <td><?php echo htmlspecialchars($initial->format('j M Y')) ?></td> - <td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($initial, null)) ?></em></td> + <td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($initial, $now)) ?></em></td> <td><?php echo htmlspecialchars($until->format('j M Y')) ?></td> - <td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($until, null)) ?></em></td> + <td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($until, $now)) ?></em></td> <td><?php echo htmlspecialchars($eol->format('j M Y')) ?></td> - <td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($eol, null)) ?></em></td> + <td class="collapse-phone"><em><?php echo htmlspecialchars(format_interval($eol, $now)) ?></em></td> </tr> <?php endforeach ?> <?php endforeach ?> -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php