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

View File

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