summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-10-23 14:30:25 +0200
committerGitHub <noreply@github.com>2020-10-23 14:30:25 +0200
commit5caa8e9490e3e9b3c17a2a8feb2af2e2b6e59758 (patch)
tree2d2912c89fc644663cc1fd615f62b28c49a0f648
parent50e532047e0f85bc25f07cacd1546232d1688831 (diff)
parentaf8ed35a1bb0cc7c2505d44e0356e84e9d34b26d (diff)
downloadnextcloud-server-5caa8e9490e3e9b3c17a2a8feb2af2e2b6e59758.tar.gz
nextcloud-server-5caa8e9490e3e9b3c17a2a8feb2af2e2b6e59758.zip
Merge pull request #23642 from nextcloud/backport/23602/stable19
[stable19] Fix updates of NULL appconfig values
-rw-r--r--lib/private/AppConfig.php31
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php
index 59499c93175..8bb165fae61 100644
--- a/lib/private/AppConfig.php
+++ b/lib/private/AppConfig.php
@@ -201,12 +201,9 @@ class AppConfig implements IAppConfig {
$sql = $this->conn->getQueryBuilder();
$sql->update('appconfig')
- ->set('configvalue', $sql->createParameter('configvalue'))
- ->where($sql->expr()->eq('appid', $sql->createParameter('app')))
- ->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
- ->setParameter('configvalue', $value)
- ->setParameter('app', $app)
- ->setParameter('configkey', $key);
+ ->set('configvalue', $sql->createNamedParameter($value))
+ ->where($sql->expr()->eq('appid', $sql->createNamedParameter($app)))
+ ->andWhere($sql->expr()->eq('configkey', $sql->createNamedParameter($key)));
/*
* Only limit to the existing value for non-Oracle DBs:
@@ -214,9 +211,25 @@ class AppConfig implements IAppConfig {
* > Large objects (LOBs) are not supported in comparison conditions.
*/
if (!($this->conn instanceof OracleConnection)) {
- // Only update the value when it is not the same
- $sql->andWhere($sql->expr()->neq('configvalue', $sql->createParameter('configvalue')))
- ->setParameter('configvalue', $value);
+
+ /*
+ * Only update the value when it is not the same
+ * Note that NULL requires some special handling. Since comparing
+ * against null can have special results.
+ */
+
+ if ($value === null) {
+ $sql->andWhere(
+ $sql->expr()->isNotNull('configvalue')
+ );
+ } else {
+ $sql->andWhere(
+ $sql->expr()->orX(
+ $sql->expr()->isNull('configvalue'),
+ $sql->expr()->neq('configvalue', $sql->createNamedParameter($value))
+ )
+ );
+ }
}
$changedRow = (bool) $sql->execute();