aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/AppConfig.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2020-10-21 10:04:06 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2020-10-21 10:04:06 +0200
commitdb82d27239aac99854415e6303e8802ce1dff2b2 (patch)
tree7f9c164b5c2f6b5c30d4183a335435aa58cc35dc /lib/private/AppConfig.php
parent851e8c0ded27a6cf8d18f6cf42f2473a6fe2aa8c (diff)
downloadnextcloud-server-db82d27239aac99854415e6303e8802ce1dff2b2.tar.gz
nextcloud-server-db82d27239aac99854415e6303e8802ce1dff2b2.zip
Fix updates of NULL appconfig values
The comparisson of NULL is a bit special. So we need to handle this a tad beter else it might not replace NULL values. or allow you to set NULL values on updates. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/AppConfig.php')
-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 d3b64449879..9e36ad0cd57 100644
--- a/lib/private/AppConfig.php
+++ b/lib/private/AppConfig.php
@@ -202,12 +202,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:
@@ -215,9 +212,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();