From 885c431bd9c3094799beda88eb79c1e08fa996e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 10 May 2017 17:41:10 +0200 Subject: [PATCH] Pass the connection parameters for cache key generation That argument was added to not have key collisions for different connections. More info: https://github.com/doctrine/dbal/pull/713 --- lib/Doctrine/ORM/Query.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index 9a5ded2c7a7..6d874a8ad1a 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -19,6 +19,7 @@ namespace Doctrine\ORM; +use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\LockMode; use Doctrine\ORM\Query\Exec\AbstractSqlExecutor; use Doctrine\ORM\Query\Parser; @@ -323,13 +324,22 @@ protected function _doExecute() list($sqlParams, $types) = $this->processParameterMappings($paramMappings); - $this->evictResultSetCache($executor, $sqlParams, $types); + $this->evictResultSetCache( + $executor, + $sqlParams, + $types, + $this->_em->getConnection()->getParams() + ); return $executor->execute($this->_em->getConnection(), $sqlParams, $types); } - private function evictResultSetCache(AbstractSqlExecutor $executor, array $sqlParams, array $types) - { + private function evictResultSetCache( + AbstractSqlExecutor $executor, + array $sqlParams, + array $types, + array $connectionParams + ) { if (null === $this->_queryCacheProfile || ! $this->getExpireResultCache()) { return; } @@ -338,7 +348,7 @@ private function evictResultSetCache(AbstractSqlExecutor $executor, array $sqlPa $statements = (array) $executor->getSqlStatements(); // Type casted since it can either be a string or an array foreach ($statements as $statement) { - $cacheKeys = $this->_queryCacheProfile->generateCacheKeys($statement, $sqlParams, $types); + $cacheKeys = $this->_queryCacheProfile->generateCacheKeys($statement, $sqlParams, $types, $connectionParams); $cacheDriver->delete(reset($cacheKeys)); }