Merge pull request #23642 from nextcloud/backport/23602/stable19

[stable19] Fix updates of NULL appconfig values
This commit is contained in:
Morris Jobke 2020-10-23 14:30:25 +02:00 committed by GitHub
commit 5caa8e9490
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 9 deletions

View File

@ -201,12 +201,9 @@ class AppConfig implements IAppConfig {
$sql = $this->conn->getQueryBuilder(); $sql = $this->conn->getQueryBuilder();
$sql->update('appconfig') $sql->update('appconfig')
->set('configvalue', $sql->createParameter('configvalue')) ->set('configvalue', $sql->createNamedParameter($value))
->where($sql->expr()->eq('appid', $sql->createParameter('app'))) ->where($sql->expr()->eq('appid', $sql->createNamedParameter($app)))
->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey'))) ->andWhere($sql->expr()->eq('configkey', $sql->createNamedParameter($key)));
->setParameter('configvalue', $value)
->setParameter('app', $app)
->setParameter('configkey', $key);
/* /*
* Only limit to the existing value for non-Oracle DBs: * 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. * > Large objects (LOBs) are not supported in comparison conditions.
*/ */
if (!($this->conn instanceof OracleConnection)) { 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(); $changedRow = (bool) $sql->execute();