- Index: lib/Doctrine/ORM/AbstractQuery.php
- ===================================================================
- --- lib/Doctrine/ORM/AbstractQuery.php (revision 7127)
- +++ lib/Doctrine/ORM/AbstractQuery.php (working copy)
- -488,7 +488,7 @@
- // Check result cache
- if ($this->_useResultCache && $cacheDriver = $this->getResultCacheDriver()) {
- - $id = $this->getResultCacheId($params);
- + $id = $this->_getResultCacheId($params);
- $cached = $this->_expireResultCache ? false : $cacheDriver->fetch($id);
- if ($cached === false) {
- -541,12 +541,14 @@
- * @param array $params
- * @return string $id
- */
- - public function getResultCacheId(array $params)
- + protected function _getResultCacheId(array $params)
- {
- if ($this->_resultCacheId) {
- return $this->_resultCacheId;
- } else {
- - return md5($this->getDql() . var_export($params, true));
- + $sql = $this->getSql();
- + ksort($this->_hints);
- + return md5(implode(";", (array)$sql) . var_export($params, true) . var_export($this->_hints, true));
- }
- }
- Index: lib/Doctrine/ORM/EntityExistsException.php
- ===================================================================
- --- lib/Doctrine/ORM/EntityExistsException.php (revision 0)
- +++ lib/Doctrine/ORM/EntityExistsException.php (revision 0)
- -0,0 +1,24 @@
- +<?php
- +
- +namespace Doctrine\ORM;
- +
- +/**
- + * EntityExistsException is thrown by EntityManager when a detached Entity is being persisted.
- + *
- + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
- + * @link www.doctrine-project.com
- + * @since 1.0
- + * @version $Revision$
- + * @author Benjamin Eberlei <kontakt@beberlei.de>
- + */
- +class EntityExistsException extends ORMException
- +{
- + /**
- + * @param string $class
- + */
- + public function __construct($class)
- + {
- + parent::__construct("Entity of Type '".$class."' is already associated with the ".
- + "persistence context, you can't call persist() on it more than once.");
- + }
- +}
- \ No newline at end of file
- Property changes on: lib/Doctrine/ORM/EntityExistsException.php
- ___________________________________________________________________
- Added: svn:keywords
- + Id,Revision
- Added: svn:eol-style
- + LF
- Index: lib/Doctrine/ORM/Query.php
- ===================================================================
- --- lib/Doctrine/ORM/Query.php (revision 7127)
- +++ lib/Doctrine/ORM/Query.php (working copy)
- -173,11 +173,7 @@
- {
- // Check query cache
- if ($queryCache = $this->getQueryCacheDriver()) {
- - // Calculate hash for dql query.
- - // TODO: Probably need to include query hints in hash calculation, because query hints
- - // can have influence on the SQL.
- - // TODO: Include _maxResults and _firstResult in hash calculation
- - $hash = md5($this->getDql() . 'DOCTRINE_QUERY_CACHE_SALT');
- + $hash = $this->_getQueryCacheId();
- $cached = ($this->_expireQueryCache) ? false : $queryCache->fetch($hash);
- if ($cached === false) {
- -438,4 +434,18 @@
- $this->setHint(self::HINT_INTERNAL_ITERATION, true);
- return parent::iterate($params, $hydrationMode);
- }
- +
- + /**
- + * Generate a cache id for the query cache - reusing the Result-Cache-Id generator.
- + *
- + * The query cache
- + *
- + * @return string
- + */
- + protected function _getQueryCacheId()
- + {
- + return md5($this->_getResultCacheId(array()) .
- + 'firstResult='.$this->_firstResult.'&maxResult='.$this->_maxResults.'DOCTRINE_QUERY_CACHE_SALT'
- + );
- + }
- }
