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 daeb23e commit 9cb15be
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cake/libs/view/view.php
Expand Up @@ -386,8 +386,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 Expand Up @@ -925,4 +925,4 @@ function renderElement($name, $params = array(), $loadHelpers = false) {
}
}

?>
?>
32 changes: 31 additions & 1 deletion cake/tests/cases/libs/view/view.test.php
Expand Up @@ -706,6 +706,36 @@ function testRenderCache() {
$this->assertFalse(empty($result));
@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 Expand Up @@ -814,4 +844,4 @@ function testBadExt() {
$this->assertPattern("/<div id=\"content\">posts index<\/div>/", $result);
}
}
?>
?>

0 comments on commit 9cb15be

Please sign in to comment.