From c36da392f8e25a78dcc448ba3d2ef71b8d718ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 18 Oct 2022 18:20:08 +0200 Subject: [PATCH] Changed: - re-added `null` again https://github.com/friendica/friendica/pull/11900#discussion_r979248182 - removed null coalescing operator --- src/Security/TwoFactor/Model/AppSpecificPassword.php | 2 +- src/Util/Temporal.php | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Security/TwoFactor/Model/AppSpecificPassword.php b/src/Security/TwoFactor/Model/AppSpecificPassword.php index d984375654..6d1ef0bdcc 100644 --- a/src/Security/TwoFactor/Model/AppSpecificPassword.php +++ b/src/Security/TwoFactor/Model/AppSpecificPassword.php @@ -86,7 +86,7 @@ class AppSpecificPassword $appSpecificPasswords = DBA::toArray($appSpecificPasswordsStmt); array_walk($appSpecificPasswords, function (&$value) { - $value['ago'] = Temporal::getRelativeDate($value['last_used'] ?? ''); + $value['ago'] = Temporal::getRelativeDate($value['last_used']); $value['utc'] = $value['last_used'] ? DateTimeFormat::utc($value['last_used'], 'c') : ''; $value['local'] = $value['last_used'] ? DateTimeFormat::local($value['last_used'], 'r') : ''; }); diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 74389c44b5..cc6a078fe1 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -311,13 +311,16 @@ class Temporal * * @return string with relative date */ - public static function getRelativeDate(string $posted_date, string $format = null): string + public static function getRelativeDate(string $posted_date = null, string $format = null): string { - $localtime = $posted_date . ' UTC'; + if (empty($posted_date) || $posted_date <= DBA::NULL_DATETIME) { + return DI::l10n()->t('never'); + } + $localtime = $posted_date . ' UTC'; $abs = strtotime($localtime); - if (empty($posted_date) || $posted_date <= DBA::NULL_DATETIME || $abs === false) { + if ($abs === false) { return DI::l10n()->t('never'); }