Skip to content

Skip null groups in group manager #3884

Merged
nickvergessen merged 4 commits into
masterfrom
downstream-26956
Mar 20, 2017
Merged

Skip null groups in group manager #3884
nickvergessen merged 4 commits into
masterfrom
downstream-26956

Conversation

@MorrisJobke

Copy link
Copy Markdown
Member

@mention-bot

Copy link
Copy Markdown

@MorrisJobke, thanks for your PR! By analyzing the history of the files in this pull request, we identified @rullzer, @nickvergessen and @schiessle to be potential reviewers.

* Skip null groups in group manager (#26871)

* Skip null groups in group manager

* Also skip null groups in group manager's search function

* Add more group null checks in sharing code

* Add unit tests for null group safety in group manager

* Add unit tests for sharing code null group checks

* Added tests for null groups handling in sharing code

* Ignore moveShare optional repair in mount provider

In some cases, data is inconsistent in the oc_share table due to legacy
data. The mount provider might attempt to make it consistent but if the
target group does not exist any more it cannot work. In such case we
simply ignore the exception as it is not critical. Keeping the
exception would break user accounts as they would be unable to use
their filesystem.

* Adjust null group handing + tests

* Fix new group manager tests

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
@@ -779,7 +779,7 @@ protected function canAccessShare(\OCP\Share\IShare $share, $checkGroups = true)
if ($checkGroups && $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
$sharedWith = $this->groupManager->get($share->getSharedWith());
$user = $this->userManager->get($this->currentUser);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could also save this call for $sharedWith === null
But since this is only for an error case it's probably okay

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>

@nickvergessen nickvergessen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Added DI and fixed some code styling in the test

@icewind1991

Copy link
Copy Markdown
Member

Breaks with php5.6:

PHP Fatal error: Cannot use Test\Util\Group\Dummy as Dummy because the name is already in use in /drone/src/github.com/nextcloud/server/tests/lib/Group/ManagerTest.php on line 32

Signed-off-by: Joas Schilling <coding@schilljs.com>
@MorrisJobke

Copy link
Copy Markdown
Member Author

@karlitschek A backport to 11 of this is needed for #5636 - opened in #5636

@karlitschek

Copy link
Copy Markdown
Member

please backport 👍

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants