mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Fixes issue in CodeParser where it tries to use a class that doesn't exist
Adds context to filterFields() model override
This commit is contained in:
parent
05dc7dfa00
commit
e487f075c4
@ -846,7 +846,7 @@ class Form extends WidgetBase
|
||||
protected function applyFiltersFromModel()
|
||||
{
|
||||
if (method_exists($this->model, 'filterFields')) {
|
||||
$this->model->filterFields((object) $this->fields);
|
||||
$this->model->filterFields((object) $this->fields, $this->getContext());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,9 +155,31 @@ class CodeParser
|
||||
require_once $data['filePath'];
|
||||
}
|
||||
|
||||
if (!class_exists($className) && ($data = $this->handleCorruptCache())) {
|
||||
$className = $data['className'];
|
||||
}
|
||||
|
||||
return new $className($page, $layout, $controller);
|
||||
}
|
||||
|
||||
/**
|
||||
* In some rare cases the cache file will not contain the class
|
||||
* name we expect. When this happens, destroy the corrupt file,
|
||||
* flush the request cache, and repeat the cycle.
|
||||
* @return void
|
||||
*/
|
||||
protected function handleCorruptCache()
|
||||
{
|
||||
$path = $this->getFilePath();
|
||||
if (File::isFile($path)) {
|
||||
File::delete($path);
|
||||
}
|
||||
|
||||
unset(self::$cache[$this->filePath]);
|
||||
|
||||
return $this->parse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates PHP content in order to detect syntax errors.
|
||||
* The method handles PHP errors and throws exceptions.
|
||||
|
Loading…
x
Reference in New Issue
Block a user