diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-04-25 17:42:20 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-04-25 17:42:20 +0200 |
commit | 5e57d3a0b9c42df1413c4d2245faf1bbbe768a63 (patch) | |
tree | 95fa7ba5360b3909eb8fa22d5caeee9bc79a2424 /apps | |
parent | 632159613447796b5bb7dbe3a17c194573b18b4a (diff) | |
parent | ca5b189522750dabb5c49981edbd5ece1c3d3454 (diff) | |
download | nextcloud-server-5e57d3a0b9c42df1413c4d2245faf1bbbe768a63.tar.gz nextcloud-server-5e57d3a0b9c42df1413c4d2245faf1bbbe768a63.zip |
Merge pull request #24244 from owncloud/mount-unique
don't get the config for the same mount multiple times
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/service/dbconfigservice.php | 13 | ||||
-rw-r--r-- | apps/files_external/tests/service/dbconfigservicetest.php | 11 |
2 files changed, 22 insertions, 2 deletions
diff --git a/apps/files_external/service/dbconfigservice.php b/apps/files_external/service/dbconfigservice.php index a37c541f045..9f7061eb938 100644 --- a/apps/files_external/service/dbconfigservice.php +++ b/apps/files_external/service/dbconfigservice.php @@ -322,10 +322,19 @@ class DBConfigService { private function getMountsFromQuery(IQueryBuilder $query) { $result = $query->execute(); $mounts = $result->fetchAll(); + $uniqueMounts = []; + foreach ($mounts as $mount) { + $id = $mount['mount_id']; + if (!isset($uniqueMounts[$id])) { + $uniqueMounts[$id] = $mount; + } + } + $uniqueMounts = array_values($uniqueMounts); $mountIds = array_map(function ($mount) { return $mount['mount_id']; - }, $mounts); + }, $uniqueMounts); + $mountIds = array_values(array_unique($mountIds)); $applicable = $this->getApplicableForMounts($mountIds); $config = $this->getConfigForMounts($mountIds); @@ -338,7 +347,7 @@ class DBConfigService { $mount['config'] = $config; $mount['options'] = $options; return $mount; - }, $mounts, $applicable, $config, $options); + }, $uniqueMounts, $applicable, $config, $options); } /** diff --git a/apps/files_external/tests/service/dbconfigservicetest.php b/apps/files_external/tests/service/dbconfigservicetest.php index c6d1add36b6..b088a7078d1 100644 --- a/apps/files_external/tests/service/dbconfigservicetest.php +++ b/apps/files_external/tests/service/dbconfigservicetest.php @@ -271,4 +271,15 @@ class DBConfigServiceTest extends TestCase { $mount = $this->dbConfig->getMountById($id2); $this->assertEquals('bar', $mount['auth_backend']); } + + public function testGetMountsForDuplicateByGroup() { + $id1 = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN); + + $this->dbConfig->addApplicable($id1, DBConfigService::APPLICABLE_TYPE_GROUP, 'group1'); + $this->dbConfig->addApplicable($id1, DBConfigService::APPLICABLE_TYPE_GROUP, 'group2'); + + $mounts = $this->dbConfig->getAdminMountsForMultiple(DBConfigService::APPLICABLE_TYPE_GROUP, ['group1', 'group2']); + $this->assertCount(1, $mounts); + $this->assertEquals($id1, $mounts[0]['mount_id']); + } } |