cache settings
This commit is contained in:
parent
e40df45cd9
commit
fa1f8663f3
@ -30,6 +30,7 @@ class SettingManager implements CallbackListener {
|
|||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $arrayDelimiter = ';;';
|
private $arrayDelimiter = ';;';
|
||||||
|
private $storedSettings = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new Setting Manager
|
* Construct a new Setting Manager
|
||||||
@ -75,16 +76,7 @@ class SettingManager implements CallbackListener {
|
|||||||
trigger_error($mysqli->error, E_USER_ERROR);
|
trigger_error($mysqli->error, E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove before release
|
return $result;
|
||||||
$settingTableChangesQuery = "ALTER TABLE `".self::TABLE_SETTINGS."`
|
|
||||||
MODIFY `class` VARCHAR(100) NOT NULL,
|
|
||||||
MODIFY `setting` VARCHAR(150) NOT NULL;";
|
|
||||||
$result2 = $mysqli->query($settingTableChangesQuery);
|
|
||||||
if ($mysqli->error) {
|
|
||||||
trigger_error($mysqli->error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result && $result2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -259,6 +251,12 @@ class SettingManager implements CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function getSetting($object, $settingName, $default = null) {
|
public function getSetting($object, $settingName, $default = null) {
|
||||||
$className = $this->getClassName($object);
|
$className = $this->getClassName($object);
|
||||||
|
|
||||||
|
//Check if setting is already in the ram
|
||||||
|
if (isset($this->storedSettings[$className . $settingName])) {
|
||||||
|
return $this->storedSettings[$className . $settingName];
|
||||||
|
}
|
||||||
|
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
$settingQuery = "SELECT `type`, `value` FROM `" . self::TABLE_SETTINGS . "`
|
$settingQuery = "SELECT `type`, `value` FROM `" . self::TABLE_SETTINGS . "`
|
||||||
WHERE `class` = ?
|
WHERE `class` = ?
|
||||||
@ -284,6 +282,9 @@ class SettingManager implements CallbackListener {
|
|||||||
$settingStatement->free_result();
|
$settingStatement->free_result();
|
||||||
$settingStatement->close();
|
$settingStatement->close();
|
||||||
$setting = $this->castSetting($type, $value);
|
$setting = $this->castSetting($type, $value);
|
||||||
|
|
||||||
|
//Store setting in the ram
|
||||||
|
$this->storedSettings[$className . $settingName] = $setting;
|
||||||
return $setting;
|
return $setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,6 +318,11 @@ class SettingManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
$settingStatement->close();
|
$settingStatement->close();
|
||||||
|
|
||||||
|
//FIXME store changed value
|
||||||
|
if (isset($this->storedSettings[$className . $settingName])) {
|
||||||
|
unset($this->storedSettings[$className . $settingName]);
|
||||||
|
}
|
||||||
|
|
||||||
//Trigger settings changed Callback
|
//Trigger settings changed Callback
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_SETTINGS_CHANGED, $className, $settingName, $value);
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_SETTINGS_CHANGED, $className, $settingName, $value);
|
||||||
return $success;
|
return $success;
|
||||||
|
Loading…
Reference in New Issue
Block a user