From 7c2907805184107e464dab2bfd0743df77ea9ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 18 Feb 2024 11:32:14 +0100 Subject: [PATCH 1/4] Treat '0' as a legitimate trim char Because of a loose comparison, it was not. --- src/Query/AST/Functions/TrimFunction.php | 2 +- tests/Tests/ORM/Query/LanguageRecognitionTest.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Query/AST/Functions/TrimFunction.php b/src/Query/AST/Functions/TrimFunction.php index 8c2b307faea..f9c6e406fea 100644 --- a/src/Query/AST/Functions/TrimFunction.php +++ b/src/Query/AST/Functions/TrimFunction.php @@ -74,7 +74,7 @@ public function parse(Parser $parser) $this->trimChar = $lexer->token->value; } - if ($this->leading || $this->trailing || $this->both || $this->trimChar) { + if ($this->leading || $this->trailing || $this->both || ($this->trimChar !== false)) { $parser->match(Lexer::T_FROM); } diff --git a/tests/Tests/ORM/Query/LanguageRecognitionTest.php b/tests/Tests/ORM/Query/LanguageRecognitionTest.php index 4d1972593f3..a2e0e600969 100644 --- a/tests/Tests/ORM/Query/LanguageRecognitionTest.php +++ b/tests/Tests/ORM/Query/LanguageRecognitionTest.php @@ -172,6 +172,11 @@ public function testFunctionalExpressionsSupportedInWherePart(): void $this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'"); } + public function testTrimFalsyString(): void + { + $this->assertValidDQL("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM('0' FROM u.name) = 'someone'"); + } + public function testArithmeticExpressionsSupportedInWherePart(): void { $this->assertValidDQL('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000'); From cf408ad9ae817948e66fc5c6487a28bc2e5b98ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 18 Feb 2024 12:26:18 +0100 Subject: [PATCH 2/4] Remove unused baseline entries --- psalm-baseline.xml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 34b44307ff3..3123bf33d28 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1543,15 +1543,6 @@ - - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - ArithmeticPrimary()]]> ArithmeticPrimary()]]> @@ -1572,15 +1563,6 @@ - - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - intervalExpression->dispatch($sqlWalker)]]> - unit->value]]> From e4769d319146cde533429a381a6fa3636203e3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sun, 18 Feb 2024 15:51:05 +0100 Subject: [PATCH 3/4] docs: recommend safer way to disable logging (#11269) * Remove trailing newlines * Recommend safer way to disable logging Resetting the middlewares on the configuration object will only work if the connection object hasn't been built from that configuration object yet. Instead, people should find the logger bound to the logging middleware and disable it. --- docs/en/reference/batch-processing.rst | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/en/reference/batch-processing.rst b/docs/en/reference/batch-processing.rst index 12cac934164..ee381bbe5c4 100644 --- a/docs/en/reference/batch-processing.rst +++ b/docs/en/reference/batch-processing.rst @@ -18,14 +18,20 @@ especially what the strategies presented here provide help with. .. note:: - Having an SQL logger enabled when processing batches can have a serious impact on performance and resource usage. - To avoid that you should remove the corresponding middleware. - To remove all middlewares, you can use this line: + Having an SQL logger enabled when processing batches can have a + serious impact on performance and resource usage. + To avoid that, you should use a PSR logger implementation that can be + disabled at runtime. + For example, with Monolog, you can use ``Logger::pushHandler()`` + to push a ``NullHandler`` to the logger instance, and then pop it + when you need to enable logging again. + + With DBAL 2, you can disable the SQL logger like below: + .. code-block:: php getConnection()->getConfiguration()->setMiddlewares([]); // DBAL 3 - $em->getConnection()->getConfiguration()->setSQLLogger(null); // DBAL 2 + $em->getConnection()->getConfiguration()->setSQLLogger(null); Bulk Inserts ------------ @@ -188,6 +194,3 @@ problems using the following approach: Iterating results is not possible with queries that fetch-join a collection-valued association. The nature of such SQL result sets is not suitable for incremental hydration. - - - From 0efac091417a499e88fe2907b0699d4f5fbf6ffd Mon Sep 17 00:00:00 2001 From: Karoly Gossler Date: Wed, 21 Feb 2024 18:51:21 +0100 Subject: [PATCH 4/4] Fix Static Analysis folder reference (#11281) --- .github/workflows/static-analysis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index c21e5cbea56..88b7196e357 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -10,7 +10,7 @@ on: - src/** - phpstan* - psalm* - - tests/Doctrine/StaticAnalysis/** + - tests/StaticAnalysis/** push: branches: - "*.x" @@ -20,7 +20,7 @@ on: - src/** - phpstan* - psalm* - - tests/Doctrine/StaticAnalysis/** + - tests/StaticAnalysis/** jobs: static-analysis-phpstan: