summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-01-18 16:58:08 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-18 16:58:08 +0100
commite895ce69fec4b691c9915ba1b94e10d0a003f9f5 (patch)
tree71be9d7fad1eed0695fd0bf51a9afbf8b0eaa8a2
parente3b6642a919d5125eda22a24c807f50cd7e6c574 (diff)
parent0b7fc9fd11394bf1e4ee13de8210678bd3c1f80d (diff)
downloadnextcloud-server-e895ce69fec4b691c9915ba1b94e10d0a003f9f5.tar.gz
nextcloud-server-e895ce69fec4b691c9915ba1b94e10d0a003f9f5.zip
Merge pull request #21757 from owncloud/files-external-applicable-db-fix
Correctly remove global applicable
-rw-r--r--apps/files_external/service/dbconfigservice.php10
-rw-r--r--apps/files_external/tests/service/dbconfigservicetest.php12
2 files changed, 20 insertions, 2 deletions
diff --git a/apps/files_external/service/dbconfigservice.php b/apps/files_external/service/dbconfigservice.php
index 94debcd7ebe..d52bf51e4aa 100644
--- a/apps/files_external/service/dbconfigservice.php
+++ b/apps/files_external/service/dbconfigservice.php
@@ -294,8 +294,14 @@ class DBConfigService {
$builder = $this->connection->getQueryBuilder();
$query = $builder->delete('external_applicable')
->where($builder->expr()->eq('mount_id', $builder->createNamedParameter($mountId, \PDO::PARAM_INT)))
- ->andWhere($builder->expr()->eq('type', $builder->createNamedParameter($type, \PDO::PARAM_INT)))
- ->andWhere($builder->expr()->eq('value', $builder->createNamedParameter($value, \PDO::PARAM_STR)));
+ ->andWhere($builder->expr()->eq('type', $builder->createNamedParameter($type, \PDO::PARAM_INT)));
+
+ if (is_null($value)) {
+ $query = $query->andWhere($builder->expr()->isNull('value'));
+ } else {
+ $query = $query->andWhere($builder->expr()->eq('value', $builder->createNamedParameter($value, \PDO::PARAM_STR)));
+ }
+
$query->execute();
}
diff --git a/apps/files_external/tests/service/dbconfigservicetest.php b/apps/files_external/tests/service/dbconfigservicetest.php
index 2ee4c232c0d..41b5df73613 100644
--- a/apps/files_external/tests/service/dbconfigservicetest.php
+++ b/apps/files_external/tests/service/dbconfigservicetest.php
@@ -124,6 +124,18 @@ class DBConfigServiceTest extends TestCase {
$this->assertEquals([], $mount['applicable']);
}
+ public function testRemoveApplicableGlobal() {
+ $id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
+ $this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
+ $this->dbConfig->removeApplicable($id, DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
+ $this->dbConfig->addApplicable($id, DBConfigService::APPLICABLE_TYPE_USER, 'test');
+
+ $mount = $this->dbConfig->getMountById($id);
+ $this->assertEquals([
+ ['type' => DBConfigService::APPLICABLE_TYPE_USER, 'value' => 'test', 'mount_id' => $id]
+ ], $mount['applicable']);
+ }
+
public function testSetConfig() {
$id = $this->addMount('/test', 'foo', 'bar', 100, DBConfigService::MOUNT_TYPE_ADMIN);
$this->dbConfig->setConfig($id, 'foo', 'bar');