From e05d7d1791e275ac93cd5a4924c9c70372271add Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 17 Dec 2011 12:19:34 -0500 Subject: [PATCH] Make dispatcher::cached() use here() This allows separate cache files to be created for different query parameters. Fixes #2381 --- lib/Cake/Routing/Dispatcher.php | 4 ++-- lib/Cake/Test/Case/Routing/DispatcherTest.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index 959fef24213..4c4909d7050 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -68,7 +68,7 @@ public function __construct($base = false) { * are encountered. */ public function dispatch(CakeRequest $request, CakeResponse $response, $additionalParams = array()) { - if ($this->asset($request->url, $response) || $this->cached($request->here)) { + if ($this->asset($request->url, $response) || $this->cached($request->here())) { return; } @@ -203,7 +203,7 @@ protected function _loadRoutes() { /** * Outputs cached dispatch view cache * - * @param string $path Requested URL path + * @param string $path Requested URL path with any query string parameters * @return string|boolean False if is not cached or output */ public function cached($path) { diff --git a/lib/Cake/Test/Case/Routing/DispatcherTest.php b/lib/Cake/Test/Case/Routing/DispatcherTest.php index b827c60234d..77521d7ed89 100644 --- a/lib/Cake/Test/Case/Routing/DispatcherTest.php +++ b/lib/Cake/Test/Case/Routing/DispatcherTest.php @@ -1360,6 +1360,7 @@ public function testAssetFilterForThemeAndPlugins() { * - Test simple views * - Test views with nocache tags * - Test requests with named + passed params. + * - Test requests with query string params * - Test themed views. * * @return array @@ -1373,6 +1374,7 @@ public static function cacheActionProvider() { array('TestCachedPages/test_nocache_tags'), array('test_cached_pages/view/param/param'), array('test_cached_pages/view/foo:bar/value:goo'), + array('test_cached_pages/view?q=cakephp'), array('test_cached_pages/themed'), ); } @@ -1405,7 +1407,7 @@ public function testFullPageCachingDispatch($url) { $out = ob_get_clean(); ob_start(); - $dispatcher->cached($request->here); + $dispatcher->cached($request->here()); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); @@ -1414,7 +1416,7 @@ public function testFullPageCachingDispatch($url) { $this->assertEquals($expected, $result); - $filename = $this->__cachePath($request->here); + $filename = $this->__cachePath($request->here()); unlink($filename); }