Recent Posts
Delphi | 6 sec ago
None | 10 sec ago
Lua | 27 sec ago
None | 30 sec ago
C++ | 31 sec ago
Bash | 43 sec ago
None | 45 sec ago
PHP | 46 sec ago
None | 48 sec ago
None | 50 sec ago
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 9th of Feb 2010 10:36:14 PM Download | Raw | Embed | Report
  1. ndex: 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/Query.php
  32. ===================================================================
  33. --- lib/Doctrine/ORM/Query.php  (revision 7127)
  34. +++ lib/Doctrine/ORM/Query.php  (working copy)
  35.  -173,11 +173,7 @@
  36.      {
  37.          // Check query cache
  38.          if ($queryCache = $this->getQueryCacheDriver()) {
  39. -            // Calculate hash for dql query.
  40. -            // TODO: Probably need to include query hints in hash calculation, because query hints
  41. -            //       can have influence on the SQL.
  42. -            // TODO: Include _maxResults and _firstResult in hash calculation
  43. -            $hash = md5($this->getDql() . 'DOCTRINE_QUERY_CACHE_SALT');
  44. +            $hash = $this->_getQueryCacheId();
  45.              $cached = ($this->_expireQueryCache) ? false : $queryCache->fetch($hash);
  46.  
  47.              if ($cached === false) {
  48.  -438,4 +434,21 @@
  49.          $this->setHint(self::HINT_INTERNAL_ITERATION, true);
  50.          return parent::iterate($params, $hydrationMode);
  51.      }
  52. +
  53. +    /**
  54. +     * Generate a cache id for the query cache - reusing the Result-Cache-Id generator.
  55. +     *
  56. +     * The query cache
  57. +     *
  58. +     * @return string
  59. +     */
  60. +    protected function _getQueryCacheId()
  61. +    {
  62. +        ksort($this->_hints);
  63. +
  64. +        return md5(
  65. +            $this->getDql() . var_export($this->_hints, true) .
  66. +            'firstResult='.$this->_firstResult.'&maxResult='.$this->_maxResults.'DOCTRINE_QUERY_CACHE_SALT'
  67. +        );
  68. +    }
  69.  }
  70. \ No newline at end of file
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: