mirror of https://github.com/MISP/MISP
chg: [internal] Fix setting cleanDb admin setting
parent
751839ad8f
commit
28afe209ca
|
@ -18,16 +18,27 @@ class AdminSetting extends AppModel
|
|||
|
||||
public function changeSetting($setting, $value = false)
|
||||
{
|
||||
$setting_object = $this->find('first', array(
|
||||
'conditions' => array('setting' => $setting)
|
||||
$existing = $this->find('first', array(
|
||||
'conditions' => array('setting' => $setting),
|
||||
'fields' => ['id'],
|
||||
));
|
||||
$this->deleteAll(array('setting' => $setting));
|
||||
$this->create();
|
||||
$setting_object['AdminSetting'] = array('setting' => $setting, 'value' => $value);
|
||||
if ($this->save($setting_object)) {
|
||||
return true;
|
||||
if ($existing) {
|
||||
if ($this->save([
|
||||
'id' => $existing['AdminSetting']['id'],
|
||||
'value' => $value,
|
||||
])) {
|
||||
return true;
|
||||
} else {
|
||||
return $this->validationErrors;
|
||||
}
|
||||
} else {
|
||||
return $this->validationErrors;
|
||||
$this->create();
|
||||
$existing['AdminSetting'] = array('setting' => $setting, 'value' => $value);
|
||||
if ($this->save($existing)) {
|
||||
return true;
|
||||
} else {
|
||||
return $this->validationErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2368,7 +2368,7 @@ class AppModel extends Model
|
|||
private function __runCleanDB()
|
||||
{
|
||||
$cleanDB = $this->AdminSetting->getSetting('clean_db');
|
||||
if (empty($cleanDB) || $cleanDB == 1) {
|
||||
if ($cleanDB === false || $cleanDB == 1) {
|
||||
$this->cleanCacheFiles();
|
||||
$this->AdminSetting->changeSetting('clean_db', 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue