From 5bb49feef805cab740a17da903f584ddbb3240f8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 2 Nov 2021 23:42:57 +0100 Subject: Allow NULL as well for limit, not integer only Signed-off-by: Joas Schilling --- lib/private/DB/Connection.php | 11 ++++++++--- lib/private/DB/QueryBuilder/QueryBuilder.php | 12 ++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'lib/private') diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 58d8d114705..1965bb3eee4 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -189,15 +189,20 @@ class Connection extends \Doctrine\DBAL\Connection { * Prepares an SQL statement. * * @param string $statement The SQL statement to prepare. - * @param int $limit - * @param int $offset + * @param int|null $limit + * @param int|null $offset * * @return Statement The prepared statement. * @throws Exception */ public function prepare($statement, $limit = null, $offset = null): Statement { - if ($limit === -1) { + if ($limit === -1 || $limit === null) { $limit = null; + } else { + $limit = (int) $limit; + } + if ($offset !== null) { + $offset = (int) $offset; } if (!is_null($limit)) { $platform = $this->getDatabasePlatform(); diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index e1f74f5327c..89265c74fae 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -450,12 +450,12 @@ class QueryBuilder implements IQueryBuilder { /** * Sets the position of the first result to retrieve (the "offset"). * - * @param integer $firstResult The first result to return. + * @param int $firstResult The first result to return. * * @return $this This QueryBuilder instance. */ public function setFirstResult($firstResult) { - $this->queryBuilder->setFirstResult($firstResult); + $this->queryBuilder->setFirstResult((int) $firstResult); return $this; } @@ -477,12 +477,16 @@ class QueryBuilder implements IQueryBuilder { * of the databases will just return an empty result set, Oracle will return * all entries. * - * @param integer $maxResults The maximum number of results to retrieve. + * @param int|null $maxResults The maximum number of results to retrieve. * * @return $this This QueryBuilder instance. */ public function setMaxResults($maxResults) { - $this->queryBuilder->setMaxResults($maxResults); + if ($maxResults === null) { + $this->queryBuilder->setMaxResults($maxResults); + } else { + $this->queryBuilder->setMaxResults((int) $maxResults); + } return $this; } -- cgit v1.2.3