]> git.mxchange.org Git - friendica.git/commitdiff
Handle null value for last_used fields in TrustedBrowsers and AppSpecificPassword
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 23 Jan 2022 02:10:20 +0000 (21:10 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 23 Jan 2022 02:10:20 +0000 (21:10 -0500)
- Remove obsolete reference to DBA::NULL_DATETIME

src/Module/Settings/TwoFactor/Trusted.php
src/Security/TwoFactor/Model/AppSpecificPassword.php

index 61289c1f88f5742f733745b954e806ca498103a5..12327a5918961af3875de186faa5d6b48acb23f7 100644 (file)
@@ -107,12 +107,12 @@ class Trusted extends BaseSettings
 
                $trustedBrowserDisplay = array_map(function (TwoFactor\Model\TrustedBrowser $trustedBrowser) use ($parser) {
                        $dates = [
-                               'created_ago' => Temporal::getRelativeDate($trustedBrowser->created),
-                               'created_utc' => DateTimeFormat::utc($trustedBrowser->created, 'c'),
-                               'created_local' => DateTimeFormat::local($trustedBrowser->created, 'r'),
-                               'last_used_ago' => Temporal::getRelativeDate($trustedBrowser->last_used),
-                               'last_used_utc' => DateTimeFormat::utc($trustedBrowser->last_used, 'c'),
-                               'last_used_local' => DateTimeFormat::local($trustedBrowser->last_used, 'r'),
+                               'created_ago'     => Temporal::getRelativeDate($trustedBrowser->created),
+                               'created_utc'     => DateTimeFormat::utc($trustedBrowser->created, 'c'),
+                               'created_local'   => DateTimeFormat::local($trustedBrowser->created, 'r'),
+                               'last_used_ago'   => Temporal::getRelativeDate($trustedBrowser->last_used),
+                               'last_used_utc'   => $trustedBrowser->last_used ? DateTimeFormat::utc($trustedBrowser->last_used, 'c') : '',
+                               'last_used_local' => $trustedBrowser->last_used ? DateTimeFormat::local($trustedBrowser->last_used, 'r') : '',
                        ];
 
                        $result = $parser->parse($trustedBrowser->user_agent);
index 13e03c6639fe7f7dce5347d9c1b7da4d60926f27..6d1ef0bdcc8e5b9a09f3f1551e38812d484828e7 100644 (file)
@@ -86,11 +86,9 @@ class AppSpecificPassword
                $appSpecificPasswords = DBA::toArray($appSpecificPasswordsStmt);
 
                array_walk($appSpecificPasswords, function (&$value) {
-                       $last_used = $value['last_used'] ?? DBA::NULL_DATETIME;
-
-                       $value['ago'] = Temporal::getRelativeDate($last_used);
-                       $value['utc'] = DateTimeFormat::utc($last_used, 'c');
-                       $value['local'] = DateTimeFormat::local($last_used, 'r');
+                       $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') : '';
                });
 
                return $appSpecificPasswords;