summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-07-18 12:15:34 +0200
committerRobin Appelman <icewind@owncloud.com>2013-07-18 12:15:34 +0200
commite3ea3ed3c563fce2b5fe1addfe199e3aaec7abdb (patch)
tree52fc58e3b1a46b1045223e869e83a7c104e97f21
parent63df8f350084c2e90419419e425697da8eff8a27 (diff)
downloadnextcloud-server-e3ea3ed3c563fce2b5fe1addfe199e3aaec7abdb.tar.gz
nextcloud-server-e3ea3ed3c563fce2b5fe1addfe199e3aaec7abdb.zip
group: only pass backends that hold that specific group to the group constructor
-rw-r--r--lib/group/group.php2
-rw-r--r--lib/group/manager.php8
-rw-r--r--tests/lib/group/group.php4
-rw-r--r--tests/lib/group/manager.php10
4 files changed, 13 insertions, 11 deletions
diff --git a/lib/group/group.php b/lib/group/group.php
index d4036b4361b..7a639313247 100644
--- a/lib/group/group.php
+++ b/lib/group/group.php
@@ -225,7 +225,7 @@ class Group {
$this->emitter->emit('\OC\Group', 'preDelete', array($this));
}
foreach ($this->backends as $backend) {
- if ($backend->implementsActions(OC_GROUP_BACKEND_DELETE_GROUP) and $backend->groupExists($this->gid)) {
+ if ($backend->implementsActions(OC_GROUP_BACKEND_DELETE_GROUP)) {
$result = true;
$backend->deleteGroup($this->gid);
}
diff --git a/lib/group/manager.php b/lib/group/manager.php
index 7efcff0ade0..bf469d51d12 100644
--- a/lib/group/manager.php
+++ b/lib/group/manager.php
@@ -85,7 +85,13 @@ class Manager extends PublicEmitter {
}
protected function getGroupObject($gid) {
- $this->cachedGroups[$gid] = new Group($gid, $this->backends, $this->userManager, $this);
+ $backends = array();
+ foreach ($this->backends as $backend) {
+ if ($backend->groupExists($gid)) {
+ $backends[] = $backend;
+ }
+ }
+ $this->cachedGroups[$gid] = new Group($gid, $backends, $this->userManager, $this);
return $this->cachedGroups[$gid];
}
diff --git a/tests/lib/group/group.php b/tests/lib/group/group.php
index 116aefda81c..75e975d9e65 100644
--- a/tests/lib/group/group.php
+++ b/tests/lib/group/group.php
@@ -307,10 +307,6 @@ class Group extends \PHPUnit_Framework_TestCase {
$backend->expects($this->once())
->method('deleteGroup')
->with('group1');
- $backend->expects($this->once())
- ->method('groupExists')
- ->with('group1')
- ->will($this->returnValue(true));
$backend->expects($this->any())
->method('implementsActions')
->will($this->returnValue(true));
diff --git a/tests/lib/group/manager.php b/tests/lib/group/manager.php
index 2ecaefc1406..9d3adf51a0c 100644
--- a/tests/lib/group/manager.php
+++ b/tests/lib/group/manager.php
@@ -17,7 +17,7 @@ class Manager extends \PHPUnit_Framework_TestCase {
* @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend
*/
$backend = $this->getMock('\OC_Group_Database');
- $backend->expects($this->once())
+ $backend->expects($this->any())
->method('groupExists')
->with('group1')
->will($this->returnValue(true));
@@ -85,7 +85,7 @@ class Manager extends \PHPUnit_Framework_TestCase {
* @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend1
*/
$backend1 = $this->getMock('\OC_Group_Database');
- $backend1->expects($this->once())
+ $backend1->expects($this->any())
->method('groupExists')
->with('group1')
->will($this->returnValue(false));
@@ -94,7 +94,7 @@ class Manager extends \PHPUnit_Framework_TestCase {
* @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend2
*/
$backend2 = $this->getMock('\OC_Group_Database');
- $backend2->expects($this->once())
+ $backend2->expects($this->any())
->method('groupExists')
->with('group1')
->will($this->returnValue(true));
@@ -117,7 +117,7 @@ class Manager extends \PHPUnit_Framework_TestCase {
* @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend
*/
$backend = $this->getMock('\OC_Group_Database');
- $backend->expects($this->once())
+ $backend->expects($this->any())
->method('groupExists')
->with('group1')
->will($this->returnValue(false));
@@ -143,7 +143,7 @@ class Manager extends \PHPUnit_Framework_TestCase {
* @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend
*/
$backend = $this->getMock('\OC_Group_Database');
- $backend->expects($this->once())
+ $backend->expects($this->any())
->method('groupExists')
->with('group1')
->will($this->returnValue(true));