Skip to content
Snippets Groups Projects
Unverified Commit 9976e470 authored by Christoph Wurst's avatar Christoph Wurst Committed by GitHub
Browse files

Merge pull request #23602 from nextcloud/fix/appconfig_update_null

Fix updates of NULL appconfig values
parents bd4c9d97 db82d272
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment