Fix comparing the empty string for global credentials
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
97b0402984
commit
a66591ee79
|
@ -307,12 +307,18 @@ class Connection extends ReconnectWrapper implements IDBConnection {
|
||||||
$where = $updateQb->expr()->andX();
|
$where = $updateQb->expr()->andX();
|
||||||
$whereValues = array_merge($keys, $updatePreconditionValues);
|
$whereValues = array_merge($keys, $updatePreconditionValues);
|
||||||
foreach ($whereValues as $name => $value) {
|
foreach ($whereValues as $name => $value) {
|
||||||
|
if ($value === '') {
|
||||||
|
$where->add($updateQb->expr()->emptyString(
|
||||||
|
$name
|
||||||
|
));
|
||||||
|
} else {
|
||||||
$where->add($updateQb->expr()->eq(
|
$where->add($updateQb->expr()->eq(
|
||||||
$name,
|
$name,
|
||||||
$updateQb->createNamedParameter($value, $this->getType($value)),
|
$updateQb->createNamedParameter($value, $this->getType($value)),
|
||||||
$this->getType($value)
|
$this->getType($value)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$updateQb->where($where);
|
$updateQb->where($where);
|
||||||
$affected = $updateQb->execute();
|
$affected = $updateQb->execute();
|
||||||
|
|
||||||
|
|
|
@ -81,9 +81,13 @@ class CredentialsManager implements ICredentialsManager {
|
||||||
$qb = $this->dbConnection->getQueryBuilder();
|
$qb = $this->dbConnection->getQueryBuilder();
|
||||||
$qb->select('credentials')
|
$qb->select('credentials')
|
||||||
->from(self::DB_TABLE)
|
->from(self::DB_TABLE)
|
||||||
->where($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)))
|
->where($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)));
|
||||||
->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
|
|
||||||
;
|
if ($userId === '') {
|
||||||
|
$qb->andWhere($qb->expr()->emptyString('user'));
|
||||||
|
} else {
|
||||||
|
$qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)));
|
||||||
|
}
|
||||||
|
|
||||||
$qResult = $qb->execute();
|
$qResult = $qb->execute();
|
||||||
$result = $qResult->fetch();
|
$result = $qResult->fetch();
|
||||||
|
@ -107,9 +111,14 @@ class CredentialsManager implements ICredentialsManager {
|
||||||
public function delete($userId, $identifier) {
|
public function delete($userId, $identifier) {
|
||||||
$qb = $this->dbConnection->getQueryBuilder();
|
$qb = $this->dbConnection->getQueryBuilder();
|
||||||
$qb->delete(self::DB_TABLE)
|
$qb->delete(self::DB_TABLE)
|
||||||
->where($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)))
|
->where($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)));
|
||||||
->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
|
|
||||||
;
|
if ($userId === '') {
|
||||||
|
$qb->andWhere($qb->expr()->emptyString('user'));
|
||||||
|
} else {
|
||||||
|
$qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)));
|
||||||
|
}
|
||||||
|
|
||||||
return $qb->execute();
|
return $qb->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue