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 NULL users? #8765

Closed
wants to merge 1 commit into from
Closed

Fix NULL users? #8765

wants to merge 1 commit into from

Conversation

Shinrai
Copy link

@Shinrai Shinrai commented Mar 10, 2018

When the following options are enabled in Nextcloud 13.0.0 the ContactsMenu fails to load.

Restrict users to only share with users in their groups
Allow username autocompletion in share dialog. If this is disabled the full username or email address needs to be entered.

The issue is traced back to:

/lib/private/Contacts/ContactsMenu/ContactsStore.php

$contactGroups = $this->groupManager->getUserGroupIds($this->userManager->get($entry->getProperty('UID')));

You'll get the error:

TypeError: Argument 1 passed to OC\Group\Manager::getUserGroupIds() must implement interface OCP\IUser, null given, called in /nextcloud/lib/private/Contacts/ContactsMenu/ContactsStore.php on line 161

When the following options are enabled in Nextcloud 13.0.0 the ContactsMenu fails to load.
```
Restrict users to only share with users in their groups
Allow username autocompletion in share dialog. If this is disabled the full username or email address needs to be entered.
```

The issue is traced back to:
### /lib/private/Contacts/ContactsMenu/ContactsStore.php
```PHP
$contactGroups = $this->groupManager->getUserGroupIds($this->userManager->get($entry->getProperty('UID')));
```

You'll get the error:
```
TypeError: Argument 1 passed to OC\Group\Manager::getUserGroupIds() must implement interface OCP\IUser, null given, called in /nextcloud/lib/private/Contacts/ContactsMenu/ContactsStore.php on line 161
```
@ChristophWurst ChristophWurst self-assigned this Mar 12, 2018
@ChristophWurst ChristophWurst added bug 3. to review Waiting for reviews labels Mar 12, 2018
@ChristophWurst ChristophWurst self-requested a review March 12, 2018 21:05
@ChristophWurst
Copy link
Member

Argument 1 passed to OC\Group\Manager::getUserGroupIds() must implement interface OCP\IUser, null given, called in /nextcloud/lib/private/Contacts/ContactsMenu/ContactsStore.php

Regression of #5585. @LEDfan would you mind taking a look? I'd suggest to check whether the user manager actually returns a user for the given UID before passing it to the group manager.

@ChristophWurst ChristophWurst added 1. to develop Accepted and waiting to be taken care of regression and removed 3. to review Waiting for reviews labels Mar 19, 2018
@@ -323,7 +323,7 @@ public function isInGroup($userId, $group) {
* @param IUser $user
* @return array with group ids
*/
public function getUserGroupIds(IUser $user) {
public function getUserGroupIds(IUser $user = null) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather fix the code that calls the method incorrectly than fixing it here. See #8765 (comment)

@MorrisJobke
Copy link
Member

Correct NULL should not be passed in. Just check before calling if it is not null. Thus closing this.

@Shinrai
Copy link
Author

Shinrai commented Apr 12, 2018

This was closed without any fix referenced. This issue is not one of a third party code but one of Nextcloud itself. As originally stated the issue happens when specific options are selected in the settings.

@Shinrai Shinrai mentioned this pull request Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of bug regression
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants