mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #1334 from thegallagher/2.3-cache-fix
Fix content-type header in cached views. Fixes #2358
This commit is contained in:
commit
e454f2d2a3
3 changed files with 6 additions and 3 deletions
|
@ -60,6 +60,7 @@ class CacheDispatcher extends DispatcherFilter {
|
|||
if (file_exists($filename)) {
|
||||
$controller = null;
|
||||
$view = new View($controller);
|
||||
$view->response = $event->data['response'];
|
||||
$result = $view->renderCache($filename, microtime(true));
|
||||
if ($result !== false) {
|
||||
$event->stopPropagation();
|
||||
|
|
|
@ -307,7 +307,7 @@ class CacheHelper extends AppHelper {
|
|||
|
||||
$file .= '
|
||||
$request = unserialize(base64_decode(\'' . base64_encode(serialize($this->request)) . '\'));
|
||||
$response = new CakeResponse();
|
||||
$response->type(\'' . $this->_View->response->type() . '\');
|
||||
$controller = new ' . $this->_View->name . 'Controller($request, $response);
|
||||
$controller->plugin = $this->plugin = \'' . $this->_View->plugin . '\';
|
||||
$controller->helpers = $this->helpers = unserialize(base64_decode(\'' . base64_encode(serialize($this->_View->helpers)) . '\'));
|
||||
|
|
|
@ -547,10 +547,12 @@ class View extends Object {
|
|||
* @return boolean Success of rendering the cached file.
|
||||
*/
|
||||
public function renderCache($filename, $timeStart) {
|
||||
$response = $this->response;
|
||||
ob_start();
|
||||
include ($filename);
|
||||
|
||||
if (Configure::read('debug') > 0 && $this->layout !== 'xml') {
|
||||
$type = $response->mapType($response->type());
|
||||
if (Configure::read('debug') > 0 && $type === 'html') {
|
||||
echo "<!-- Cached Render Time: " . round(microtime(true) - $timeStart, 4) . "s -->";
|
||||
}
|
||||
$out = ob_get_clean();
|
||||
|
@ -564,7 +566,7 @@ class View extends Object {
|
|||
return false;
|
||||
} else {
|
||||
if ($this->layout === 'xml') {
|
||||
header('Content-type: text/xml');
|
||||
$response->type('xml');
|
||||
}
|
||||
return substr($out, strlen($match[0]));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue