diff options
author | Joas Schilling <coding@schilljs.com> | 2021-11-02 23:42:57 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-11-15 18:51:28 +0100 |
commit | 5bb49feef805cab740a17da903f584ddbb3240f8 (patch) | |
tree | c19a3fd143948ca696c5d9575a079afb25df8e79 /lib | |
parent | 788a1fcca4b84e7bcf8f93826c968688077a81f9 (diff) | |
download | nextcloud-server-5bb49feef805cab740a17da903f584ddbb3240f8.tar.gz nextcloud-server-5bb49feef805cab740a17da903f584ddbb3240f8.zip |
Allow NULL as well for limit, not integer only
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/DB/Connection.php | 11 | ||||
-rw-r--r-- | lib/private/DB/QueryBuilder/QueryBuilder.php | 12 | ||||
-rw-r--r-- | lib/public/DB/QueryBuilder/IQueryBuilder.php | 4 | ||||
-rw-r--r-- | lib/public/IDBConnection.php | 4 |
4 files changed, 20 insertions, 11 deletions
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; } diff --git a/lib/public/DB/QueryBuilder/IQueryBuilder.php b/lib/public/DB/QueryBuilder/IQueryBuilder.php index 5d1116075d8..7829696970c 100644 --- a/lib/public/DB/QueryBuilder/IQueryBuilder.php +++ b/lib/public/DB/QueryBuilder/IQueryBuilder.php @@ -280,7 +280,7 @@ interface 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. * @since 8.2.0 @@ -299,7 +299,7 @@ interface IQueryBuilder { /** * Sets the maximum number of results to retrieve (the "limit"). * - * @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. * @since 8.2.0 diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php index cedf0429869..2fa7fa1ad36 100644 --- a/lib/public/IDBConnection.php +++ b/lib/public/IDBConnection.php @@ -86,8 +86,8 @@ interface IDBConnection { /** * Used to abstract the ownCloud database access away * @param string $sql the sql query with ? placeholder for params - * @param int $limit the maximum number of rows - * @param int $offset from which row we want to start + * @param int|null $limit the maximum number of rows + * @param int|null $offset from which row we want to start * @return IPreparedStatement The prepared statement. * @since 6.0.0 * @throws Exception since 21.0.0 |