Changeset 7724
- Timestamp:
- 03/03/08 14:35:23 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/plugins/sfCompat10Plugin/lib/helper/PartialHelper.php
r7717 r7724 114 114 { 115 115 $cacheManager->registerConfiguration($moduleName); 116 if ($retval = $cacheManager->getPartialCache($moduleName, $actionName, $ vars))116 if ($retval = $cacheManager->getPartialCache($moduleName, $actionName, $cacheManager->computeCacheKey($vars))) 117 117 { 118 118 return $retval; … … 177 177 if ($cacheManager) 178 178 { 179 $retval = $cacheManager->setPartialCache($moduleName, $actionName, $ vars, $retval);179 $retval = $cacheManager->setPartialCache($moduleName, $actionName, $cacheManager->computeCacheKey($vars), $retval); 180 180 } 181 181 … … 242 242 $cacheManager->registerConfiguration($moduleName); 243 243 $uri = '@sf_cache_partial?module='.$moduleName.'&action='.$actionName.'&sf_cache_key='.(isset($vars['sf_cache_key']) ? $vars['sf_cache_key'] : md5(serialize($vars))); 244 if ($retval = $cacheManager->getPartialCache($moduleName, $actionName, $ vars))244 if ($retval = $cacheManager->getPartialCache($moduleName, $actionName, $cacheManager->computeCacheKey($vars))) 245 245 { 246 246 return $retval; … … 255 255 if ($cacheManager) 256 256 { 257 $retval = $cacheManager->setPartialCache($moduleName, $actionName, $ vars, $retval);257 $retval = $cacheManager->setPartialCache($moduleName, $actionName, $cacheManager->computeCacheKey($vars), $retval); 258 258 } 259 259 branches/1.1/lib/view/sfViewCacheManager.class.php
r7723 r7724 520 520 } 521 521 522 public function computeCacheKey($parameters) 522 /** 523 * Computes the cache key based on the passed parameters. 524 * 525 * @param array An array of parameters 526 */ 527 public function computeCacheKey(array $parameters) 523 528 { 524 529 return isset($parameters['sf_cache_key']) ? $parameters['sf_cache_key'] : md5(serialize($parameters)); 525 530 } 526 531 527 public function getPartialUri($module, $action, $parameters) 528 { 529 return sprintf('@sf_cache_partial?module=%s&action=%s&sf_cache_key=%s', $module, $action, $this->computeCacheKey($parameters)); 532 /** 533 * Computes a partial internal URI. 534 * 535 * @param string The module name 536 * @param string The action name 537 * @param string The cache key 538 * 539 * @return string The internal URI 540 */ 541 public function getPartialUri($module, $action, $cacheKey) 542 { 543 return sprintf('@sf_cache_partial?module=%s&action=%s&sf_cache_key=%s', $module, $action, $cacheKey); 530 544 } 531 545 … … 533 547 * Returns whether a partial template is in the cache. 534 548 * 535 * @param string The internal URI 549 * @param string The module name 550 * @param string The action name 551 * @param string The cache key 536 552 * 537 553 * @return Boolean true if a partial is in the cache, false otherwise 538 554 */ 539 public function hasPartialCache($module, $action, $ parameters)540 { 541 return $this->has($this->getPartialUri($module, $action, $ parameters));555 public function hasPartialCache($module, $action, $cacheKey) 556 { 557 return $this->has($this->getPartialUri($module, $action, $cacheKey)); 542 558 } 543 559 … … 545 561 * Gets a partial template from the cache. 546 562 * 547 * @param string The internal URI 563 * @param string The module name 564 * @param string The action name 565 * @param string The cache key 548 566 * 549 567 * @return string The cache content 550 568 */ 551 public function getPartialCache($module, $action, $ parameters)552 { 553 $uri = $this->getPartialUri($module, $action, $ parameters);569 public function getPartialCache($module, $action, $cacheKey) 570 { 571 $uri = $this->getPartialUri($module, $action, $cacheKey); 554 572 555 573 if (!$this->isCacheable($uri)) … … 581 599 * Sets an action template in the cache. 582 600 * 583 * @param string The internal URI 601 * @param string The module name 602 * @param string The action name 603 * @param string The cache key 584 604 * @param string The content to cache 585 * @param string The view attribute holder to cache586 605 * 587 606 * @return string The cached content 588 607 */ 589 public function setPartialCache($module, $action, $ parameters, $content)590 { 591 $uri = $this->getPartialUri($module, $action, $ parameters);608 public function setPartialCache($module, $action, $cacheKey, $content) 609 { 610 $uri = $this->getPartialUri($module, $action, $cacheKey); 592 611 if (!$this->isCacheable($uri)) 593 612 {