Skip to content

Commit

Permalink
Merge pull request #6436 from lcobucci/fix-result-set-cache-eviction
Browse files Browse the repository at this point in the history
Pass the connections parameters for cache key generation
  • Loading branch information
lcobucci authored May 10, 2017
2 parents 7bb02d0 + 885c431 commit 2695f5e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/Doctrine/ORM/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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));
}
Expand Down

0 comments on commit 2695f5e

Please sign in to comment.