diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index 2c97819ba..14a720ba2 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -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()); } } diff --git a/modules/cms/classes/CodeParser.php b/modules/cms/classes/CodeParser.php index a566d4972..f381e2f37 100644 --- a/modules/cms/classes/CodeParser.php +++ b/modules/cms/classes/CodeParser.php @@ -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.