diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 29c352f69..ec85d2650 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -77,12 +77,15 @@ class CacheHelper extends AppHelper { $cacheTime = 0; $useCallbacks = false; if (is_array($this->cacheAction)) { + $contoller = Inflector::underscore($this->controllerName); $check = str_replace('/', '_', $this->here); $replace = str_replace('/', '_', $this->base); $match = str_replace($this->base, '', $this->here); $match = str_replace('//', '/', $match); + $match = str_replace('/' . $contoller . '/', '', $match); $match = str_replace('/' . $this->controllerName . '/', '', $match); $check = str_replace($replace, '', $check); + $check = str_replace('_' . $contoller . '_', '', $check); $check = str_replace('_' . $this->controllerName . '_', '', $check); $check = Inflector::slug($check); $check = preg_replace('/^_+/', '', $check); diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 40a0f11d9..1dab259b6 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -402,7 +402,10 @@ class TestCachedPagesController extends AppController { * @var array * @access public */ - var $cacheAction = array('index'=> '+2 sec', 'test_nocache_tags'=>'+2 sec'); + var $cacheAction = array( + 'index'=> '+2 sec', 'test_nocache_tags'=>'+2 sec', + 'view/' => '+2 sec' + ); /** * viewPath property * @@ -426,9 +429,17 @@ class TestCachedPagesController extends AppController { * @return void */ function test_nocache_tags() { -//$this->cacheAction = '+2 sec'; $this->render(); } +/** + * view method + * + * @access public + * @return void + */ + function view($id = null) { + $this->render('index'); + } } /** * TimesheetsController class @@ -1466,6 +1477,24 @@ class DispatcherTest extends CakeTestCase { $this->assertEqual($result, $expected); $filename = $this->__cachePath($dispatcher->here); unlink($filename); + + $url = 'test_cached_pages/view/param/param'; + + ob_start(); + $dispatcher->dispatch($url); + $out = ob_get_clean(); + + ob_start(); + $dispatcher->cached($url); + $cached = ob_get_clean(); + + $result = str_replace(array("\t", "\r\n", "\n"), "", $out); + $cached = preg_replace('//', '', $cached); + $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); + + $this->assertEqual($result, $expected); + $filename = $this->__cachePath($dispatcher->here); + unlink($filename); } /** * testHttpMethodOverrides method