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

Condition in JFactory::getUser() never false #10543

Closed
alex-filat opened this issue May 18, 2016 · 5 comments
Closed

Condition in JFactory::getUser() never false #10543

alex-filat opened this issue May 18, 2016 · 5 comments

Comments

@alex-filat
Copy link
Contributor

alex-filat commented May 18, 2016

Steps to reproduce the issue

Request the user with active user id
f.e. JFactory::getUser(308), assuming logged in user's id is 308

Expected result

below condition must be false
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/factory.php#L246
elseif (!($instance instanceof JUser) || is_string($id) || $instance->id !== $id)

Actual result

but this condition alway true becouse
$instance->id !== $id is always true because $instance->id is string type and $id must be not string type

@infograf768
Copy link
Member

As far as I know, $id is also a string

object(JUser)[33]
  protected 'isRoot' => null
  public 'id' => string '122' (length=3)

```<hr /><sub>This comment was created with the <a href="https://github.com/joomla/jissues">J!Tracker Application</a> at <a href="https://issues.joomla.org/tracker/joomla-cms/10543">issues.joomla.org/joomla-cms/10543</a>.</sub>

@alex-filat
Copy link
Contributor Author

That is the problem. If we pass id type string then condition is true and function will create new user instead of return the existing.

@Quy
Copy link
Contributor

Quy commented Dec 8, 2017

Since is_string($id) condition is true, the last condition will not be evaluated. This issue can be closed.

@joomla-cms-bot
Copy link

Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/10543

@ghost
Copy link

ghost commented Dec 9, 2017

closed as stated above.

Thanks @Quy.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/10543.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants