Skip to content

Commit

Permalink
[DDC-1766] Cleaned up code.
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Apr 4, 2012
1 parent d31c7f5 commit f7496b1
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/Doctrine/ORM/AbstractQuery.php
Expand Up @@ -329,10 +329,12 @@ public function setResultSetMapping(Query\ResultSetMapping $rsm)
public function setHydrationCacheProfile(QueryCacheProfile $profile = null)
{
if ( ! $profile->getResultCacheDriver()) {
$profile = $profile->setResultCacheDriver($this->_em->getConfiguration()->getResultCacheImpl());
$resultCacheDriver = $this->_em->getConfiguration()->getResultCacheImpl();
$profile = $profile->setResultCacheDriver($resultCacheDriver);
}

$this->_hydrationCacheProfile = $profile;

return $this;
}

Expand All @@ -356,10 +358,12 @@ public function getHydrationCacheProfile()
public function setResultCacheProfile(QueryCacheProfile $profile = null)
{
if ( ! $profile->getResultCacheDriver()) {
$profile = $profile->setResultCacheDriver($this->_em->getConfiguration()->getResultCacheImpl());
$resultCacheDriver = $this->_em->getConfiguration()->getResultCacheImpl();
$profile = $profile->setResultCacheDriver($resultCacheDriver);
}

$this->_queryCacheProfile = $profile;

return $this;
}

Expand Down Expand Up @@ -709,13 +713,14 @@ public function execute($params = array(), $hydrationMode = null)
}

$setCacheEntry = function() {};

if ($this->_hydrationCacheProfile !== null) {
list($cacheKey, $realCacheKey) = $this->getHydrationCacheId();

$qcp = $this->getHydrationCacheProfile();
$cache = $qcp->getResultCacheDriver();

$qcp = $this->getHydrationCacheProfile();
$cache = $qcp->getResultCacheDriver();
$result = $cache->fetch($cacheKey);

if (isset($result[$realCacheKey])) {
return $result[$realCacheKey];
}
Expand All @@ -734,6 +739,7 @@ public function execute($params = array(), $hydrationMode = null)

if (is_numeric($stmt)) {
$setCacheEntry($stmt);

return $stmt;
}

Expand All @@ -756,6 +762,7 @@ public function execute($params = array(), $hydrationMode = null)
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) {
Expand Down

0 comments on commit f7496b1

Please sign in to comment.