From 813d222bf4ba44b93d54225cd2d8c260cf66720e Mon Sep 17 00:00:00 2001 From: mokaddem Date: Thu, 12 Sep 2019 14:10:17 +0200 Subject: [PATCH] chg: [decaying] Added log entry if formula cannot be loaded --- app/Controller/LogsController.php | 2 +- app/Model/DecayingModel.php | 21 ++++++++++++++++++--- app/Model/Log.php | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/Controller/LogsController.php b/app/Controller/LogsController.php index fdd2134cc..dd2f7fb9f 100644 --- a/app/Controller/LogsController.php +++ b/app/Controller/LogsController.php @@ -416,7 +416,7 @@ class LogsController extends AppController $this->set('actions', $actions); // combobox for models - $models = array('Attribute', 'Event', 'EventBlacklist', 'EventTag', 'MispObject', 'Organisation', 'Post', 'Regexp', 'Role', 'Server', 'ShadowAttribute', 'SharingGroup', 'Tag', 'Task', 'Taxonomy', 'Template', 'Thread', 'User', 'Whitelist'); + $models = array('Attribute', 'Event', 'EventBlacklist', 'EventTag', 'DecayingModel', 'MispObject', 'Organisation', 'Post', 'Regexp', 'Role', 'Server', 'ShadowAttribute', 'SharingGroup', 'Tag', 'Task', 'Taxonomy', 'Template', 'Thread', 'User', 'Whitelist'); $models = array('' => 'ALL') + $this->_arrayToValuesIndexArray($models); $this->set('models', $models); $this->set('actionDefinitions', $this->{$this->defaultModel}->actionDefinitions); diff --git a/app/Model/DecayingModel.php b/app/Model/DecayingModel.php index 5d3c9ab1c..e5eacb3ed 100644 --- a/app/Model/DecayingModel.php +++ b/app/Model/DecayingModel.php @@ -351,9 +351,24 @@ class DecayingModel extends AppModel $full_path = APP . 'Model/DecayingModelsFormulas/' . $formula_files[$index]; if (is_file($full_path)) { include_once $full_path; - $model_class = ClassRegistry::init($expected_classname); - if ($model_class->checkLoading() === 'BONFIRE LIT') { - return $model_class; + try { + $model_class = ClassRegistry::init($expected_classname); + if ($model_class->checkLoading() === 'BONFIRE LIT') { + return $model_class; + } + } catch (Exception $e) { + $this->Log = ClassRegistry::init('Log'); + $this->Log->create(); + $this->Log->save(array( + 'org' => 'SYSTEM', + 'model' => 'DecayingModel', + 'model_id' => 0, + 'email' => 'SYSTEM', + 'action' => 'include_formula', + 'title' => sprintf('Error while trying to include file `%s`: %s', $filename, $e->getMessage()), + 'change' => '' + )); + return false; } } } diff --git a/app/Model/Log.php b/app/Model/Log.php index 4748fcba8..31209cbd3 100644 --- a/app/Model/Log.php +++ b/app/Model/Log.php @@ -35,6 +35,7 @@ class Log extends AppModel 'export', 'file_upload', 'galaxy', + 'include_formula', 'login', 'login_fail', 'logout',