From d48be34696176666cd2cc6d841158d790910c638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Bere=C5=88?= Date: Thu, 28 Aug 2014 13:17:25 +0200 Subject: [PATCH] CS Fixes --- lib/Doctrine/ORM/Tools/Pagination/CountWalker.php | 5 +++-- lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php | 3 ++- lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php index 5294ab0a4..0aa6aebfc 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/CountWalker.php @@ -53,12 +53,13 @@ class CountWalker extends TreeWalkerAdapter $queryComponents = $this->_getQueryComponents(); // Get the root entity and alias from the AST fromClause $from = $AST->fromClause->identificationVariableDeclarations; + if (count($from) > 1) { throw new \RuntimeException("Cannot count query which selects two FROM components, cannot make distinction"); } - $rootAlias = $from[0]->rangeVariableDeclaration->aliasIdentificationVariable; - $rootClass = $queryComponents[$rootAlias]['metadata']; + $rootAlias = $from[0]->rangeVariableDeclaration->aliasIdentificationVariable; + $rootClass = $queryComponents[$rootAlias]['metadata']; $identifierFieldName = $rootClass->getSingleIdentifierFieldName(); $pathType = PathExpression::TYPE_STATE_FIELD; diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php index c8cc4f7c0..342e309b1 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryWalker.php @@ -62,7 +62,7 @@ class LimitSubqueryWalker extends TreeWalkerAdapter { $queryComponents = $this->_getQueryComponents(); // Get the root entity and alias from the AST fromClause - $from = $AST->fromClause->identificationVariableDeclarations; + $from = $AST->fromClause->identificationVariableDeclarations; $rootAlias = $from[0]->rangeVariableDeclaration->aliasIdentificationVariable; $rootClass = $queryComponents[$rootAlias]['metadata']; $selectExpressions = array(); @@ -76,6 +76,7 @@ class LimitSubqueryWalker extends TreeWalkerAdapter } $identifier = $rootClass->getSingleIdentifierFieldName(); + if (isset($rootClass->associationMappings[$identifier])) { throw new \RuntimeException("Paginating an entity with foreign key as identifier only works when using the Output Walkers. Call Paginator#setUseOutputWalkers(true) before iterating the paginator."); } diff --git a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php index 936d6f103..2584b8ef9 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/WhereInWalker.php @@ -74,12 +74,13 @@ class WhereInWalker extends TreeWalkerAdapter $queryComponents = $this->_getQueryComponents(); // Get the root entity and alias from the AST fromClause $from = $AST->fromClause->identificationVariableDeclarations; + if (count($from) > 1) { throw new \RuntimeException("Cannot count query which selects two FROM components, cannot make distinction"); } - $rootAlias = $from[0]->rangeVariableDeclaration->aliasIdentificationVariable; - $rootClass = $queryComponents[$rootAlias]['metadata']; + $rootAlias = $from[0]->rangeVariableDeclaration->aliasIdentificationVariable; + $rootClass = $queryComponents[$rootAlias]['metadata']; $identifierFieldName = $rootClass->getSingleIdentifierFieldName(); $pathType = PathExpression::TYPE_STATE_FIELD;