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)
|
public function changeSetting($setting, $value = false)
|
||||||
{
|
{
|
||||||
$setting_object = $this->find('first', array(
|
$existing = $this->find('first', array(
|
||||||
'conditions' => array('setting' => $setting)
|
'conditions' => array('setting' => $setting),
|
||||||
|
'fields' => ['id'],
|
||||||
));
|
));
|
||||||
$this->deleteAll(array('setting' => $setting));
|
if ($existing) {
|
||||||
$this->create();
|
if ($this->save([
|
||||||
$setting_object['AdminSetting'] = array('setting' => $setting, 'value' => $value);
|
'id' => $existing['AdminSetting']['id'],
|
||||||
if ($this->save($setting_object)) {
|
'value' => $value,
|
||||||
return true;
|
])) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return $this->validationErrors;
|
||||||
|
}
|
||||||
} else {
|
} 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()
|
private function __runCleanDB()
|
||||||
{
|
{
|
||||||
$cleanDB = $this->AdminSetting->getSetting('clean_db');
|
$cleanDB = $this->AdminSetting->getSetting('clean_db');
|
||||||
if (empty($cleanDB) || $cleanDB == 1) {
|
if ($cleanDB === false || $cleanDB == 1) {
|
||||||
$this->cleanCacheFiles();
|
$this->cleanCacheFiles();
|
||||||
$this->AdminSetting->changeSetting('clean_db', 0);
|
$this->AdminSetting->changeSetting('clean_db', 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue