mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
fixes #4086 caching with params
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7388 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
b6e9888753
commit
a4499befe3
2 changed files with 34 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue