From f36470941c6d6f62d91632a7745e3638ec9150bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Sun, 18 Feb 2018 23:19:46 +0100 Subject: [PATCH] Fix BC-break on delete queries with nasty workaround The `v2.5.x` series of the ORM allowed to have DELETE DQLs without using an alias, even though it didn't follow the grammar rules of the parser. We fixed that issue on `v2.6.0` however that was a BC-breaking change and lots of people were relying on this faulty behaviour. This workaround fixes the BC-break, without even trying to be elegant. In `v2.7.0.` we should raise a deprecation notice to notify people that we'll drop that "feature" in `v3.0`. --- lib/Doctrine/ORM/Query/Parser.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index e726aa062..e8c8104bd 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -22,6 +22,7 @@ namespace Doctrine\ORM\Query; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Query; use Doctrine\ORM\Query\AST\Functions; +use function strpos; /** * An LL(*) recursive-descent parser for the context-free grammar of the Doctrine Query Language. @@ -1280,7 +1281,9 @@ class Parser $this->match(Lexer::T_AS); } - $aliasIdentificationVariable = $this->AliasIdentificationVariable(); + $aliasIdentificationVariable = $this->lexer->isNextToken(Lexer::T_IDENTIFIER) + ? $this->AliasIdentificationVariable() + : 'alias_should_have_been_set'; $deleteClause->aliasIdentificationVariable = $aliasIdentificationVariable; $class = $this->em->getClassMetadata($deleteClause->abstractSchemaName);