From 7e8fd2c639f0f28a3eaf2f62cf98ca0f37ec5396 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 25 Apr 2016 13:50:19 +0200 Subject: [PATCH] don't get the config for the same mount multiple times --- apps/files_external/service/dbconfigservice.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/files_external/service/dbconfigservice.php b/apps/files_external/service/dbconfigservice.php index a37c541f04..9f7061eb93 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); } /**