]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow NULL as well for limit, not integer only
authorJoas Schilling <coding@schilljs.com>
Tue, 2 Nov 2021 22:42:57 +0000 (23:42 +0100)
committerJoas Schilling <coding@schilljs.com>
Mon, 15 Nov 2021 17:51:28 +0000 (18:51 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/DB/Connection.php
lib/private/DB/QueryBuilder/QueryBuilder.php
lib/public/DB/QueryBuilder/IQueryBuilder.php
lib/public/IDBConnection.php

index 58d8d11470558282a090183d7c6bec4831261117..1965bb3eee43c50698fc928a0644497bebbfa215 100644 (file)
@@ -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();
index e1f74f5327cac67b56c0256e3f5cb1ff27463376..89265c74fae3efce299f39b43653f03391b1513e 100644 (file)
@@ -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;
        }
index 5d1116075d8e96230bcb58c6a5888c5434297947..7829696970cdbf6a8de4703bb85f9c6fb83cbe14 100644 (file)
@@ -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
index cedf042986998e62d964b753067f6c3956cd1a6a..2fa7fa1ad3681cc16fcceb8788a12a00ea310491 100644 (file)
@@ -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