From: Roland Häder Date: Sat, 24 Sep 2022 12:11:46 +0000 (+0200) Subject: Changed according feedback: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2773ac9909195ed7c7a50ce77753831e4275c001;p=friendica.git Changed according feedback: - $posted_date should not allow NULL, instead use `?? ''` instead - this happened in e.g. 2FA app-specific password listing --- diff --git a/src/Security/TwoFactor/Model/AppSpecificPassword.php b/src/Security/TwoFactor/Model/AppSpecificPassword.php index 6d1ef0bdcc..d984375654 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 ef87f84883..74389c44b5 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -311,13 +311,13 @@ class Temporal * * @return string with relative date */ - public static function getRelativeDate(string $posted_date = null, string $format = null): string + public static function getRelativeDate(string $posted_date, string $format = null): string { $localtime = $posted_date . ' UTC'; $abs = strtotime($localtime); - if (is_null($posted_date) || $posted_date <= DBA::NULL_DATETIME || $abs === false) { + if (empty($posted_date) || $posted_date <= DBA::NULL_DATETIME || $abs === false) { return DI::l10n()->t('never'); }