Skip to content
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

Merged
merged 3 commits into from
Dec 3, 2016
Merged

Fix #2427 by converting $remember to integer #2428

merged 3 commits into from
Dec 3, 2016

Conversation

justin-sleep
Copy link
Member

@justin-sleep justin-sleep commented Nov 30, 2016

Fixes #2427

@mention-bot
Copy link

@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>
@codecov-io
Copy link

codecov-io commented Dec 1, 2016

Current coverage is 57.11% (diff: 100%)

Merging #2428 into master will increase coverage by 0.05%

@@             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          

Powered by Codecov. Last update d7dd399...25a5c65

@rullzer
Copy link
Member

rullzer commented Dec 1, 2016

@justin-sleep thanks a lot for reporting the bug and fixing it as well!

@ChristophWurst please have a look :)

@rullzer rullzer added 3. to review Waiting for reviews bug labels Dec 1, 2016
@rullzer rullzer added this to the Nextcloud 11.0 milestone Dec 1, 2016
@@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(int)$remember maybe?

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member

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);
Copy link
Member

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:

$this->userSession->createSessionToken($this->request, $loginResult->getUID(), $user, $password, $remember_login);
)
or the bottom (DefaultTokenProvider:
$dbToken->setRemember($remember);
)

but not in the middle?

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup sounds good!

@MorrisJobke MorrisJobke added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Dec 2, 2016
@MorrisJobke
Copy link
Member

@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>
@justin-sleep
Copy link
Member Author

Look good?

@nickvergessen
Copy link
Member

👍

@ChristophWurst ChristophWurst self-assigned this Dec 3, 2016
@MorrisJobke MorrisJobke added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Dec 3, 2016
@MorrisJobke
Copy link
Member

MorrisJobke commented Dec 3, 2016

Tested and works 👍

@MorrisJobke MorrisJobke merged commit 9eb1ea4 into nextcloud:master Dec 3, 2016
@MorrisJobke
Copy link
Member

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants