mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-24 09:42:43 +01:00
Fix potential memory leak on controller load in Template
constructor
This commit is contained in:
parent
1dcd0f3391
commit
0a7df298f3
@ -197,6 +197,8 @@ class Formwork
|
||||
|
||||
$resource = $this->router->dispatch();
|
||||
|
||||
$resource->template()->loadController();
|
||||
|
||||
if (is_null($this->site->currentPage())) {
|
||||
$this->site->setCurrentPage($resource);
|
||||
}
|
||||
|
@ -89,7 +89,6 @@ class Template
|
||||
$this->name = $template;
|
||||
$this->page = $page;
|
||||
$this->vars = $this->defaults();
|
||||
$this->loadController();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,26 +154,10 @@ class Template
|
||||
ob_end_flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array containing the default data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function defaults()
|
||||
{
|
||||
return array(
|
||||
'params' => Formwork::instance()->router()->params(),
|
||||
'site' => Formwork::instance()->site(),
|
||||
'page' => $this->page
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load template controller if exists
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function loadController()
|
||||
public function loadController()
|
||||
{
|
||||
if ($this->rendering) {
|
||||
throw new RuntimeException(__METHOD__ . ' not allowed while rendering');
|
||||
@ -188,6 +171,20 @@ class Template
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array containing the default data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function defaults()
|
||||
{
|
||||
return array(
|
||||
'params' => Formwork::instance()->router()->params(),
|
||||
'site' => Formwork::instance()->site(),
|
||||
'page' => $this->page
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Assets instance
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user