Skip to content

Commit

Permalink
Making the cake:nocache stripping more relaxed so that if either cond…
Browse files Browse the repository at this point in the history
…ition to enable caching is on, tags will be stripped. Tests added. Fixes #1148
  • Loading branch information
markstory committed Sep 29, 2010
1 parent 9992cff commit 0761ede
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cake/libs/view/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ function render($action = null, $layout = null, $file = null) {
if ($layout && $this->autoLayout) {
$out = $this->renderLayout($out, $layout);
$isCached = (
isset($this->loaded['cache']) &&
(($this->cacheAction != false)) && (Configure::read('Cache.check') === true)
isset($this->loaded['cache']) ||
Configure::read('Cache.check') === true
);

if ($isCached) {
Expand Down
30 changes: 30 additions & 0 deletions cake/tests/cases/libs/view/view.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,36 @@ function testRenderCache() {
@unlink($path);
}

/**
* Test that render() will remove the cake:nocache tags when only the cachehelper is present.
*
* @return void
*/
function testRenderStrippingNoCacheTagsOnlyCacheHelper() {
Configure::write('Cache.check', false);
$View =& new View($this->PostsController);
$View->set(array('superman' => 'clark', 'variable' => 'var'));
$View->helpers = array('Html', 'Form', 'Cache');
$View->layout = 'cache_layout';
$result = $View->render('index');
$this->assertNoPattern('/cake:nocache/', $result);
}

/**
* Test that render() will remove the cake:nocache tags when only the Cache.check is true.
*
* @return void
*/
function testRenderStrippingNoCacheTagsOnlyCacheCheck() {
Configure::write('Cache.check', true);
$View =& new View($this->PostsController);
$View->set(array('superman' => 'clark', 'variable' => 'var'));
$View->helpers = array('Html', 'Form');
$View->layout = 'cache_layout';
$result = $View->render('index');
$this->assertNoPattern('/cake:nocache/', $result);
}

/**
* testRenderNocache method
*
Expand Down

0 comments on commit 0761ede

Please sign in to comment.