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:
Samuel Georges 2015-02-26 23:08:38 +11:00
parent 05dc7dfa00
commit e487f075c4
2 changed files with 23 additions and 1 deletions

View File

@ -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());
}
}

View File

@ -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.