]> source.dussan.org Git - nextcloud-server.git/commitdiff
Correctly remove global applicable
authorRobin McCorkell <rmccorkell@owncloud.com>
Fri, 15 Jan 2016 23:17:22 +0000 (23:17 +0000)
committerRobin McCorkell <rmccorkell@owncloud.com>
Fri, 15 Jan 2016 23:17:22 +0000 (23:17 +0000)
apps/files_external/service/dbconfigservice.php
apps/files_external/tests/service/dbconfigservicetest.php

index 94debcd7ebef865a0e1df868a92c36772bd5b78a..d52bf51e4aa936c3c91ffb662e7d374dfeba4c43 100644 (file)
@@ -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();
        }
 
index 2ee4c232c0dd50b60353b3bc50e39cff2984d5b1..41b5df736133799848d52692d28b6b09cce4dffc 100644 (file)
@@ -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');