diff options
author | Joas Schilling <coding@schilljs.com> | 2024-07-19 12:54:40 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-07-19 14:13:56 +0200 |
commit | b656edc47c50376140971e11d1325147cb1e49c9 (patch) | |
tree | c6ed85e0619d3eabfcf00fa0ae281ed4b40d2f8b /lib | |
parent | 817ca0045a4271af6737884a3424587ba29948cb (diff) | |
download | nextcloud-server-b656edc47c50376140971e11d1325147cb1e49c9.tar.gz nextcloud-server-b656edc47c50376140971e11d1325147cb1e49c9.zip |
fix(db): Fix md5 for oracle >= 20
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
4 files changed, 23 insertions, 1 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index f59c6b34836..e584690f95d 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\ConnectionLost; use Doctrine\DBAL\Platforms\MySQLPlatform; @@ -749,4 +750,13 @@ class Connection extends PrimaryReadReplicaConnection { throw new \Exception('Database ' . $platform::class . ' not supported'); } } + + /** + * @internal Should only be used inside the QueryBuilder, ExpressionBuilder and FunctionBuilder + * All apps and API code should not need this and instead use provided functionality from the above. + */ + public function getServerVersion(): string { + /** @var ServerInfoAwareConnection $this->_conn */ + return $this->_conn->getServerVersion(); + } } diff --git a/lib/private/DB/ConnectionAdapter.php b/lib/private/DB/ConnectionAdapter.php index 8a919696eaa..b7225169e4c 100644 --- a/lib/private/DB/ConnectionAdapter.php +++ b/lib/private/DB/ConnectionAdapter.php @@ -232,4 +232,12 @@ class ConnectionAdapter implements IDBConnection { public function getDatabaseProvider(): string { return $this->inner->getDatabaseProvider(); } + + /** + * @internal Should only be used inside the QueryBuilder, ExpressionBuilder and FunctionBuilder + * All apps and API code should not need this and instead use provided functionality from the above. + */ + public function getServerVersion(): string { + return $this->inner->getServerVersion(); + } } diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php index b168d2c1a84..2466493c1fa 100644 --- a/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php +++ b/lib/private/DB/QueryBuilder/FunctionBuilder/FunctionBuilder.php @@ -5,6 +5,7 @@ */ namespace OC\DB\QueryBuilder\FunctionBuilder; +use OC\DB\Connection; use OC\DB\QueryBuilder\QueryFunction; use OC\DB\QueryBuilder\QuoteHelper; use OCP\DB\QueryBuilder\IFunctionBuilder; @@ -13,7 +14,7 @@ use OCP\DB\QueryBuilder\IQueryFunction; use OCP\IDBConnection; class FunctionBuilder implements IFunctionBuilder { - /** @var IDBConnection */ + /** @var IDBConnection|Connection */ protected $connection; /** @var IQueryBuilder */ diff --git a/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php b/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php index d0258eafea8..a8dc4d8cf14 100644 --- a/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php +++ b/lib/private/DB/QueryBuilder/FunctionBuilder/OCIFunctionBuilder.php @@ -12,6 +12,9 @@ use OCP\DB\QueryBuilder\IQueryFunction; class OCIFunctionBuilder extends FunctionBuilder { public function md5($input): IQueryFunction { + if (version_compare($this->connection->getServerVersion(), '20', '>=')) { + return new QueryFunction('LOWER(STANDARD_HASH(' . $this->helper->quoteColumnName($input) . ", 'MD5'))"); + } return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))'); } |