Skip to content

Commit

Permalink
Pass the connection parameters for cache key generation
Browse files Browse the repository at this point in the history
That argument was added to not have key collisions for different
connections.

More info: doctrine/dbal#713
  • Loading branch information
lcobucci committed May 10, 2017
1 parent 7bb02d0 commit 885c431
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 885c431

Please sign in to comment.