forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DDC-1766] Rewrite getHydrationCacheId() to use existing processParam…
…eterValue() method. Other code style changes.
- Loading branch information
Showing
3 changed files
with
52 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ | |
namespace Doctrine\ORM; | ||
|
||
use Doctrine\DBAL\Types\Type, | ||
Doctrine\ORM\Query\QueryException, | ||
Doctrine\DBAL\Cache\QueryCacheProfile, | ||
Doctrine\ORM\Query\QueryException, | ||
Doctrine\ORM\Internal\Hydration\CacheHydrator; | ||
|
||
/** | ||
|
@@ -30,7 +30,6 @@ | |
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL | ||
* @link www.doctrine-project.org | ||
* @since 2.0 | ||
* @version $Revision$ | ||
* @author Benjamin Eberlei <[email protected]> | ||
* @author Guilherme Blanco <[email protected]> | ||
* @author Jonathan Wage <[email protected]> | ||
|
@@ -329,7 +328,7 @@ public function setResultSetMapping(Query\ResultSetMapping $rsm) | |
public function setHydrationCacheProfile(QueryCacheProfile $profile = null) | ||
{ | ||
if ( ! $profile->getResultCacheDriver()) { | ||
$resultCacheDriver = $this->_em->getConfiguration()->getResultCacheImpl(); | ||
$resultCacheDriver = $this->_em->getConfiguration()->getHydrationCacheImpl(); | ||
$profile = $profile->setResultCacheDriver($resultCacheDriver); | ||
} | ||
|
||
|
@@ -717,9 +716,9 @@ public function execute($params = array(), $hydrationMode = null) | |
if ($this->_hydrationCacheProfile !== null) { | ||
list($cacheKey, $realCacheKey) = $this->getHydrationCacheId(); | ||
|
||
$qcp = $this->getHydrationCacheProfile(); | ||
$cache = $qcp->getResultCacheDriver(); | ||
$result = $cache->fetch($cacheKey); | ||
$queryCacheProfile = $this->getHydrationCacheProfile(); | ||
$cache = $queryCacheProfile->getResultCacheDriver(); | ||
$result = $cache->fetch($cacheKey); | ||
|
||
if (isset($result[$realCacheKey])) { | ||
return $result[$realCacheKey]; | ||
|
@@ -729,9 +728,9 @@ public function execute($params = array(), $hydrationMode = null) | |
$result = array(); | ||
} | ||
|
||
$setCacheEntry = function($data) use ($cache, $result, $cacheKey, $realCacheKey, $qcp) { | ||
$setCacheEntry = function($data) use ($cache, $result, $cacheKey, $realCacheKey, $queryCacheProfile) { | ||
$result[$realCacheKey] = $data; | ||
$cache->save($cacheKey, $result, $qcp->getLifetime()); | ||
$cache->save($cacheKey, $result, $queryCacheProfile->getLifetime()); | ||
}; | ||
} | ||
|
||
|
@@ -764,24 +763,16 @@ protected function getHydrationCacheId() | |
$params = $this->getParameters(); | ||
|
||
foreach ($params AS $key => $value) { | ||
if (is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(get_class($value))) { | ||
if ($this->_em->getUnitOfWork()->getEntityState($value) == UnitOfWork::STATE_MANAGED) { | ||
$idValues = $this->_em->getUnitOfWork()->getEntityIdentifier($value); | ||
} else { | ||
$class = $this->_em->getClassMetadata(get_class($value)); | ||
$idValues = $class->getIdentifierValues($value); | ||
} | ||
$params[$key] = $idValues; | ||
} | ||
$params[$key] = $this->processParameterValue($value); | ||
} | ||
|
||
$sql = $this->getSQL(); | ||
$queryCacheProfile = $this->getHydrationCacheProfile(); | ||
$hints = $this->getHints(); | ||
$hints['hydrationMode'] = $this->getHydrationMode(); | ||
$qcp = $this->getHydrationCacheProfile(); | ||
ksort($hints); | ||
|
||
return $qcp->generateCacheKeys($sql, $params, $hints); | ||
return $queryCacheProfile->generateCacheKeys($sql, $params, $hints); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters