aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2023-11-30 13:41:20 +0100
committerJulius Härtl <jus@bitgrid.net>2023-11-30 20:51:48 +0100
commit3cd1d74a815531c9b7ae25ebbf8e7c45fa566e74 (patch)
tree40ced9b7d214db78732d14e09fd8ee47bb0ea8fe
parenta3a343ce413d0f86f70d5b47ab28e40d6dd763aa (diff)
downloadnextcloud-server-3cd1d74a815531c9b7ae25ebbf8e7c45fa566e74.tar.gz
nextcloud-server-3cd1d74a815531c9b7ae25ebbf8e7c45fa566e74.zip
fix: Only apply cast if needed when searching users for value
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--lib/private/AllConfig.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php
index 2a0e8f53b14..92178d64635 100644
--- a/lib/private/AllConfig.php
+++ b/lib/private/AllConfig.php
@@ -32,6 +32,7 @@
*/
namespace OC;
+use Doctrine\DBAL\Platforms\OraclePlatform;
use OCP\Cache\CappedMemoryCache;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
@@ -490,12 +491,15 @@ class AllConfig implements IConfig {
$this->fixDIInit();
$qb = $this->connection->getQueryBuilder();
+ $configValueColumn = ($this->connection->getDatabasePlatform() instanceof OraclePlatform)
+ ? $qb->expr()->castColumn('configvalue', IQueryBuilder::PARAM_STR)
+ : 'configvalue';
$result = $qb->select('userid')
->from('preferences')
->where($qb->expr()->eq('appid', $qb->createNamedParameter($appName, IQueryBuilder::PARAM_STR)))
->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter($key, IQueryBuilder::PARAM_STR)))
->andWhere($qb->expr()->eq(
- $qb->expr()->castColumn('configvalue', IQueryBuilder::PARAM_STR),
+ $configValueColumn,
$qb->createNamedParameter($value, IQueryBuilder::PARAM_STR))
)->orderBy('userid')
->executeQuery();
@@ -524,13 +528,18 @@ class AllConfig implements IConfig {
// Email address is always stored lowercase in the database
return $this->getUsersForUserValue($appName, $key, strtolower($value));
}
+
$qb = $this->connection->getQueryBuilder();
+ $configValueColumn = ($this->connection->getDatabasePlatform() instanceof OraclePlatform)
+ ? $qb->expr()->castColumn('configvalue', IQueryBuilder::PARAM_STR)
+ : 'configvalue';
+
$result = $qb->select('userid')
->from('preferences')
->where($qb->expr()->eq('appid', $qb->createNamedParameter($appName, IQueryBuilder::PARAM_STR)))
->andWhere($qb->expr()->eq('configkey', $qb->createNamedParameter($key, IQueryBuilder::PARAM_STR)))
->andWhere($qb->expr()->eq(
- $qb->func()->lower($qb->expr()->castColumn('configvalue', IQueryBuilder::PARAM_STR)),
+ $qb->func()->lower($configValueColumn),
$qb->createNamedParameter(strtolower($value), IQueryBuilder::PARAM_STR))
)->orderBy('userid')
->executeQuery();