From d3ab948d88b2e555878ab329440f14fa903eb133 Mon Sep 17 00:00:00 2001 From: Kirill chEbba Chebunin Date: Mon, 20 Aug 2012 16:27:52 +0400 Subject: [PATCH] Overwrite query limits only if set in QueryBuilder::addCriteria() --- lib/Doctrine/ORM/QueryBuilder.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/QueryBuilder.php b/lib/Doctrine/ORM/QueryBuilder.php index 0a31953f2..1e8d5653b 100644 --- a/lib/Doctrine/ORM/QueryBuilder.php +++ b/lib/Doctrine/ORM/QueryBuilder.php @@ -1024,7 +1024,7 @@ class QueryBuilder * Add criteria to query. * Add where expressions with AND operator. * Add orderings. - * Override firstResult and maxResults. + * Override firstResult and maxResults if they set. * * @param Criteria $criteria * @return QueryBuilder @@ -1046,8 +1046,13 @@ class QueryBuilder } } - $this->setFirstResult($criteria->getFirstResult()); - $this->setMaxResults($criteria->getMaxResults()); + // Overwrite limits only if they was set in criteria + if (($firstResult = $criteria->getFirstResult()) !== null) { + $this->setFirstResult($firstResult); + } + if (($maxResults = $criteria->getMaxResults()) !== null) { + $this->setMaxResults($maxResults); + } return $this; }