-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: correctly record the datetime for last_active
#404
fix: correctly record the datetime for last_active
#404
Conversation
I think we've fixed this bug in the past. |
@kenjis, This bug was created from #392. Oh, maybe you mean problem |
@kenjis see here!! public function recordActiveDate(): void
{
if (! $this->user instanceof User) {
throw new InvalidArgumentException(
__METHOD__ . '() requires logged in user before calling.'
);
}
-$this->user->last_active = Time::now()->format('Y-m-d H:i:s');
+$time = Time::now()->format('Y-m-d H:i:s');
+$this->user->last_active = $time;
+echo ($time);
+echo ($this->user->last_active);
+exit;
$this->provider->updateActiveDate($this->user);
}
output : 2022-08-26 23:10:12 and ۲۰۲۲-۰۸-۲۶ ۲۳:۱۰:۱۲ way? Is it related to Handling Business Logic?!؟ Temporary solution: |
oh! I noticed something. Line 37 in b7b6720
And then $this->user->last_active = Time::now()->format('Y-m-d H:i:s'); The date is recorded without any problems! |
@datamweb Ah, you're correct! Date mutator converts date string to Time object. This is a problem in the database layer. |
It is valid.
|
That was my faulty approval. I didn't realize that the |
I thought that. But if we convert it to string, it will lose the timezone. |
e5b43af
to
b7b6720
Compare
I don't like to have a PR about shield/src/Entities/UserIdentity.php Lines 37 to 40 in b7b6720
|
The coding rule that we must follow now is:
So the following code is incorrect, because it passes a Time object. $time = Time::now();
$this->builder->set('last_active', $time) But it works in locale en, etc. Because it will be converted to string like I would like to fix it as a bug to work in all locales, because Time is a CI4 standard class. |
0726dbc
to
0d96d73
Compare
We can continue this discussion on the framework issue, but just to reinforce what @kenjis said:
|
Kenjis and MGatner Thanks for the review and useful information. |
Hello friends,
correctly record the datetime for last_active in case of change
defaultLocale
.Before:
After:
Ref #238