chg: [internal] Fix setting cleanDb admin setting

pull/7849/head
Jakub Onderka 2021-10-16 19:32:32 +02:00
parent 751839ad8f
commit 28afe209ca
2 changed files with 20 additions and 9 deletions

View File

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

View File

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