Skip to content
This repository
Browse code

Making the cake:nocache stripping more relaxed so that if either cond…

…ition to enable caching is on, tags will be stripped. Tests added. Fixes #1148
  • Loading branch information...
commit 9cb15be76b11d4ebdd850d1811695fe1a1458800 1 parent daeb23e
Mark Story authored September 28, 2010
6  cake/libs/view/view.php
@@ -386,8 +386,8 @@ function render($action = null, $layout = null, $file = null) {
386 386
 			if ($layout && $this->autoLayout) {
387 387
 				$out = $this->renderLayout($out, $layout);
388 388
 				$isCached = (
389  
-					isset($this->loaded['cache']) &&
390  
-					(($this->cacheAction != false)) && (Configure::read('Cache.check') === true)
  389
+					isset($this->loaded['cache']) ||
  390
+					Configure::read('Cache.check') === true
391 391
 				);
392 392
 
393 393
 				if ($isCached) {
@@ -925,4 +925,4 @@ function renderElement($name, $params = array(), $loadHelpers = false) {
925 925
 	}
926 926
 }
927 927
 
928  
-?>
  928
+?>
32  cake/tests/cases/libs/view/view.test.php
@@ -707,6 +707,36 @@ function testRenderCache() {
707 707
 		@unlink($path);
708 708
 	}
709 709
 /**
  710
+ * Test that render() will remove the cake:nocache tags when only the cachehelper is present.
  711
+ *
  712
+ * @return void
  713
+ */
  714
+	function testRenderStrippingNoCacheTagsOnlyCacheHelper() {
  715
+		Configure::write('Cache.check', false);
  716
+		$View =& new View($this->PostsController);
  717
+		$View->set(array('superman' => 'clark', 'variable' => 'var'));
  718
+		$View->helpers = array('Html', 'Form', 'Cache');
  719
+		$View->layout = 'cache_layout';
  720
+		$result = $View->render('index');
  721
+		$this->assertNoPattern('/cake:nocache/', $result);
  722
+	}
  723
+
  724
+/**
  725
+ * Test that render() will remove the cake:nocache tags when only the Cache.check is true.
  726
+ *
  727
+ * @return void
  728
+ */
  729
+	function testRenderStrippingNoCacheTagsOnlyCacheCheck() {
  730
+		Configure::write('Cache.check', true);
  731
+		$View =& new View($this->PostsController);
  732
+		$View->set(array('superman' => 'clark', 'variable' => 'var'));
  733
+		$View->helpers = array('Html', 'Form');
  734
+		$View->layout = 'cache_layout';
  735
+		$result = $View->render('index');
  736
+		$this->assertNoPattern('/cake:nocache/', $result);
  737
+	}
  738
+
  739
+/**
710 740
  * testRenderNocache method
711 741
  *
712 742
  * @access public
@@ -814,4 +844,4 @@ function testBadExt() {
814 844
 		$this->assertPattern("/<div id=\"content\">posts index<\/div>/", $result);
815 845
 	}
816 846
 }
817  
-?>
  847
+?>

0 notes on commit 9cb15be

Please sign in to comment.
Something went wrong with that request. Please try again.