Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Feb 9th, 2010 | Syntax: None | Size: 3.76 KB | Hits: 26 | Expires: Never
Copy text to clipboard
  1. Index: lib/Doctrine/ORM/AbstractQuery.php
  2. ===================================================================
  3. --- lib/Doctrine/ORM/AbstractQuery.php  (revision 7127)
  4. +++ lib/Doctrine/ORM/AbstractQuery.php  (working copy)
  5.  -488,7 +488,7 @@
  6.  
  7.          // Check result cache
  8.          if ($this->_useResultCache && $cacheDriver = $this->getResultCacheDriver()) {
  9. -            $id = $this->getResultCacheId($params);
  10. +            $id = $this->_getResultCacheId($params);
  11.              $cached = $this->_expireResultCache ? false : $cacheDriver->fetch($id);
  12.  
  13.              if ($cached === false) {
  14.  -541,12 +541,14 @@
  15.       * @param array $params
  16.       * @return string $id
  17.       */
  18. -    public function getResultCacheId(array $params)
  19. +    protected function _getResultCacheId(array $params)
  20.      {
  21.          if ($this->_resultCacheId) {
  22.              return $this->_resultCacheId;
  23.          } else {
  24. -            return md5($this->getDql() . var_export($params, true));
  25. +            $sql = $this->getSql();
  26. +            ksort($this->_hints);
  27. +            return md5(implode(";", (array)$sql) . var_export($params, true) . var_export($this->_hints, true));
  28.          }
  29.      }
  30.  
  31. Index: lib/Doctrine/ORM/EntityExistsException.php
  32. ===================================================================
  33. --- lib/Doctrine/ORM/EntityExistsException.php  (revision 0)
  34. +++ lib/Doctrine/ORM/EntityExistsException.php  (revision 0)
  35.  -0,0 +1,24 @@
  36. +<?php
  37. +
  38. +namespace Doctrine\ORM;
  39. +
  40. +/**
  41. + * EntityExistsException is thrown by EntityManager when a detached Entity is being persisted.
  42. + *
  43. + * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
  44. + * @link        www.doctrine-project.com
  45. + * @since       1.0
  46. + * @version     $Revision$
  47. + * @author      Benjamin Eberlei <kontakt@beberlei.de>
  48. + */
  49. +class EntityExistsException extends ORMException
  50. +{
  51. +    /**
  52. +     * @param string $class
  53. +     */
  54. +    public function __construct($class)
  55. +    {
  56. +        parent::__construct("Entity of Type '".$class."' is already associated with the ".
  57. +            "persistence context, you can't call persist() on it more than once.");
  58. +    }
  59. +}
  60. \ No newline at end of file
  61.  
  62. Property changes on: lib/Doctrine/ORM/EntityExistsException.php
  63. ___________________________________________________________________
  64. Added: svn:keywords
  65.    + Id,Revision
  66. Added: svn:eol-style
  67.    + LF
  68.  
  69. Index: lib/Doctrine/ORM/Query.php
  70. ===================================================================
  71. --- lib/Doctrine/ORM/Query.php  (revision 7127)
  72. +++ lib/Doctrine/ORM/Query.php  (working copy)
  73.  -173,11 +173,7 @@
  74.      {
  75.          // Check query cache
  76.          if ($queryCache = $this->getQueryCacheDriver()) {
  77. -            // Calculate hash for dql query.
  78. -            // TODO: Probably need to include query hints in hash calculation, because query hints
  79. -            //       can have influence on the SQL.
  80. -            // TODO: Include _maxResults and _firstResult in hash calculation
  81. -            $hash = md5($this->getDql() . 'DOCTRINE_QUERY_CACHE_SALT');
  82. +            $hash = $this->_getQueryCacheId();
  83.              $cached = ($this->_expireQueryCache) ? false : $queryCache->fetch($hash);
  84.  
  85.              if ($cached === false) {
  86.  -438,4 +434,18 @@
  87.          $this->setHint(self::HINT_INTERNAL_ITERATION, true);
  88.          return parent::iterate($params, $hydrationMode);
  89.      }
  90. +
  91. +    /**
  92. +     * Generate a cache id for the query cache - reusing the Result-Cache-Id generator.
  93. +     *
  94. +     * The query cache
  95. +     *
  96. +     * @return string
  97. +     */
  98. +    protected function _getQueryCacheId()
  99. +    {
  100. +        return md5($this->_getResultCacheId(array()) .
  101. +            'firstResult='.$this->_firstResult.'&maxResult='.$this->_maxResults.'DOCTRINE_QUERY_CACHE_SALT'
  102. +        );
  103. +    }
  104.  }