Permalink
Browse files

Update generated cache files.

- Cache files should contain a response object on the controller.
  Without it bad things happen.
- Include the $request and $response contructor arguments for Controller.
- Update import -> uses()

Refs #2190
  • Loading branch information...
1 parent bf43a5e commit 6623b7dc9d05eaa00192f5e010feaaa3f6dbef88 @markstory markstory committed Nov 1, 2011
Showing with 12 additions and 10 deletions.
  1. +12 −10 lib/Cake/View/Helper/CacheHelper.php
@@ -265,24 +265,26 @@ protected function _writeFile($content, $timestamp, $useCallbacks = false) {
$file = '<!--cachetime:' . $cacheTime . '--><?php';
if (empty($this->_View->plugin)) {
- $file .= '
- App::import(\'Controller\', \'' . $this->_View->name. '\');
- ';
+ $file .= "
+ App::uses('{$this->_View->name}Controller', 'Controller');
+ ";
} else {
- $file .= '
- App::import(\'Controller\', \'' . $this->_View->plugin . '.' . $this->_View->name. '\');
- ';
+ $file .= "
+ App::uses('{$this->_View->name}Controller', '{$this->_View->plugin}.Controller');
+ ";
}
- $file .= '$controller = new ' . $this->_View->name . 'Controller();
+ $file .= '
+ $request = unserialize(\'' . str_replace("'", "\\'", serialize($this->request)) . '\');
+ $response = new CakeResponse(array("charset" => Configure::read("App.encoding")));
+ $controller = new ' . $this->_View->name . 'Controller($request, $response);
$controller->plugin = $this->plugin = \'' . $this->_View->plugin . '\';
$controller->helpers = $this->helpers = unserialize(\'' . serialize($this->_View->helpers) . '\');
$controller->layout = $this->layout = \'' . $this->_View->layout. '\';
- $controller->request = $this->request = unserialize(\'' . str_replace("'", "\\'", serialize($this->request)) . '\');
$controller->theme = $this->theme = \'' . $this->_View->theme . '\';
$controller->viewVars = $this->viewVars = unserialize(base64_decode(\'' . base64_encode(serialize($this->_View->viewVars)) . '\'));
- Router::setRequestInfo($controller->request);';
-
+ Router::setRequestInfo($controller->request);
+ $this->request = $request;';
if ($useCallbacks == true) {
$file .= '

0 comments on commit 6623b7d

Please sign in to comment.