Skip to content

Commit

Permalink
Changed according feedback:
Browse files Browse the repository at this point in the history
- $posted_date should not allow NULL, instead use `?? ''` instead
- this happened in e.g. 2FA app-specific password listing
  • Loading branch information
Quix0r committed Oct 14, 2022
1 parent bcbf5bc commit 19cf4d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Security/TwoFactor/Model/AppSpecificPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function getListForUser($uid)
$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') : '';
});
Expand Down
4 changes: 2 additions & 2 deletions src/Util/Temporal.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,13 @@ public static function getDateTimeField(
*
* @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');
}

Expand Down

0 comments on commit 19cf4d8

Please sign in to comment.