-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 #2427 by converting $remember to integer #2428
Conversation
@justin-sleep, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ChristophWurst, @icewind1991 and @blizzz to be potential reviewers. |
Signed-off-by: justin-sleep <justin@quarterfull.com>
Current coverage is 57.11% (diff: 100%)@@ master #2428 diff @@
==========================================
Files 1199 1198 -1
Lines 72262 72254 -8
Methods 7347 7347
Messages 0 0
Branches 1214 1216 +2
==========================================
+ Hits 41228 41265 +37
+ Misses 31034 30989 -45
Partials 0 0
|
@justin-sleep thanks a lot for reporting the bug and fixing it as well! @ChristophWurst please have a look :) |
@@ -558,7 +558,7 @@ public function createSessionToken(IRequest $request, $uid, $loginName, $passwor | |||
try { | |||
$sessionId = $this->session->getId(); | |||
$pwd = $this->getPassword($password); | |||
$this->tokenProvider->generateToken($sessionId, $uid, $loginName, $pwd, $name, IToken::TEMPORARY_TOKEN, $remember); | |||
$this->tokenProvider->generateToken($sessionId, $uid, $loginName, $pwd, $name, IToken::TEMPORARY_TOKEN, +$remember); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(int)$remember maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it from PHP's page on arithmetic operators isn't +$remember essentially the same? Or is it better to explicitly cast as int here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the same. +$var
also would convert to float, while (int)
explicitly converts to int.
php > $s3 = '12.3';
php > $a = +$s3;
php > var_dump($a);
php shell code:1:
double(12.3)
php > $a = (int)$s3;
php > var_dump($a);
php shell code:1:
int(12)
This should not apply here, and nevertheless it's better to be crisp and clear :) Also, imho (int)
has a better readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While they might be semanticly the same. I think what @LukasReschke means more is that explicitly casting with (int) makes it more readable.
Signed-off-by: justin-sleep <justin@quarterfull.com>
@@ -558,7 +558,7 @@ public function createSessionToken(IRequest $request, $uid, $loginName, $passwor | |||
try { | |||
$sessionId = $this->session->getId(); | |||
$pwd = $this->getPassword($password); | |||
$this->tokenProvider->generateToken($sessionId, $uid, $loginName, $pwd, $name, IToken::TEMPORARY_TOKEN, $remember); | |||
$this->tokenProvider->generateToken($sessionId, $uid, $loginName, $pwd, $name, IToken::TEMPORARY_TOKEN, (int)$remember); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should either be at the top of the chain (LoginController:
server/core/Controller/LoginController.php
Line 243 in d75e35b
$this->userSession->createSessionToken($this->request, $loginResult->getUID(), $user, $password, $remember_login); |
or the bottom (DefaultTokenProvider:
$dbToken->setRemember($remember); |
but not in the middle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I think top is the way to go, because also this method states that it should be called with an integer only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup sounds good!
@justin-sleep Could I ask you to do the changes as requested above? Then this is good to get in 🚀 |
Signed-off-by: justin-sleep <justin@quarterfull.com>
Look good? |
👍 |
Tested and works 👍 |
Thanks a lot @justin-sleep - feel free to join our IRC channel #nextcloud-dev on freenode or the forums :) Maybe also check out some other starter issues in https://github.com/nextcloud/server/issues?q=is%3Aissue+is%3Aopen+label%3A%22starter+issue%22 😉 Have a nice weekend :) |
Fixes #2427