From c4a8d2cc998c5157573148c8eb17e560c5e829e0 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 1 Mar 2020 23:37:58 +0100 Subject: [PATCH] [GH-7633] HINT_FORCE_PARTIAL_LOAD still needs to be checked. --- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 2 +- .../Functional/SecondLevelCacheQueryCacheTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index e4bac034a94..83cc6128f9b 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -260,7 +260,7 @@ public function put(QueryCacheKey $key, ResultSetMapping $rsm, $result, array $h throw new CacheException("Second-level cache query supports only select statements."); } - if (isset($hints[Query\SqlWalker::HINT_PARTIAL]) && $hints[Query\SqlWalker::HINT_PARTIAL]) { + if (($hints[Query\SqlWalker::HINT_PARTIAL] ?? false) === true || ($hints[Query::HINT_FORCE_PARTIAL_LOAD] ?? false) === true) { throw new CacheException("Second level cache does not support partial entities."); } diff --git a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php index df7e95b7e4b..181229f4a02 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php @@ -1099,6 +1099,21 @@ public function testCacheablePartialQueryException() ->getResult(); } + /** + * @expectedException \Doctrine\ORM\Cache\CacheException + * @expectedExceptionMessage Second level cache does not support partial entities. + */ + public function testCacheableForcePartialLoadHintQueryException() + { + $this->evictRegions(); + $this->loadFixturesCountries(); + + $this->_em->createQuery("SELECT c FROM Doctrine\Tests\Models\Cache\Country c") + ->setCacheable(true) + ->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true) + ->getResult(); + } + /** * @expectedException \Doctrine\ORM\Cache\CacheException * @expectedExceptionMessage Second-level cache query supports only select statements.