chg: [decaying] Added log entry if formula cannot be loaded

pull/5032/head
mokaddem 2019-09-12 14:10:17 +02:00
parent cfafc2e51f
commit 813d222bf4
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
3 changed files with 20 additions and 4 deletions

View File

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

View File

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

View File

@ -35,6 +35,7 @@ class Log extends AppModel
'export',
'file_upload',
'galaxy',
'include_formula',
'login',
'login_fail',
'logout',