Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding a line to the generated cache files,

that re-assigns view params after component callbacks.
Fixes issues with SecurityComponent and cache files.
Fixes #1863
  • Loading branch information...
commit 0ddc5f1597e99b174f03ffdae7f61806f35fae76 1 parent 095c15d
@markstory markstory authored markstory committed
View
3  cake/libs/view/helpers/cache.php
@@ -308,7 +308,8 @@ function __writeFile($content, $timestamp, $useCallbacks = false) {
$controller->constructClasses();
$controller->Component->initialize($controller);
$controller->beforeFilter();
- $controller->Component->startup($controller);';
+ $controller->Component->startup($controller);
+ $this->params = $controller->params;';
}
$file .= '
View
33 cake/tests/cases/libs/view/helpers/cache.test.php
@@ -241,6 +241,39 @@ function testComplexNoCache () {
//$this->assertPattern('/6\. in element with no cache tags/', $contents);
$this->assertPattern('/7\. layout after content and after element with no cache tags/', $contents);
}
+
+ function testCacheCallbacks() {
+ $this->Controller->cache_parsing();
+ $this->Controller->params = array(
+ 'controller' => 'cache_test',
+ 'action' => 'cache_parsing',
+ 'url' => array(),
+ 'pass' => array(),
+ 'named' => array()
+ );
+ $this->Controller->cacheAction = array(
+ 'cache_parsing' => array(
+ 'duration' => 21600,
+ 'callbacks' => true
+ )
+ );
+ $this->Controller->here = '/cacheTest/cache_parsing';
+ $this->Controller->action = 'cache_parsing';
+
+ $View = new View($this->Controller);
+ $result = $View->render('index');
+
+ $filename = CACHE . 'views' . DS . 'cachetest_cache_parsing.php';
+ $this->assertTrue(file_exists($filename));
+
+ $contents = file_get_contents($filename);
+
+ $this->assertPattern('/\$controller->beforeFilter\(\);/', $contents);
+ $this->assertPattern('/\$this->params = \$controller->params;/', $contents);
+
+ @unlink($filename);
+ }
+
/**
* test cacheAction set to a boolean
*
Please sign in to comment.
Something went wrong with that request. Please try again.