fixed loading of server options on start
(property name needs to start in lower case)
This commit is contained in:
parent
fc73510e8d
commit
4ac0ec7f73
@ -100,35 +100,36 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
public function loadSettingsFromDatabase() {
|
public function loadSettingsFromDatabase() {
|
||||||
$serverId = $this->maniaControl->server->index;
|
$serverId = $this->maniaControl->server->index;
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
$query = "SELECT * FROM `" . self::TABLE_SERVER_SETTINGS . "` WHERE serverIndex = " . $serverId . ";";
|
$query = "SELECT * FROM `" . self::TABLE_SERVER_SETTINGS . "`
|
||||||
|
WHERE serverIndex = {$serverId};";
|
||||||
$result = $mysqli->query($query);
|
$result = $mysqli->query($query);
|
||||||
if ($mysqli->error) {
|
if ($mysqli->error) {
|
||||||
trigger_error($mysqli->error);
|
trigger_error($mysqli->error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$serverSettings = $this->maniaControl->client->getServerOptions();
|
$serverSettings = $this->maniaControl->client->getServerOptions();
|
||||||
$applySettings = false;
|
$savedSettings = array();
|
||||||
while ($row = $result->fetch_object()) {
|
while ($row = $result->fetch_object()) {
|
||||||
$settingName = $row->settingName;
|
$settingName = lcfirst($row->settingName);
|
||||||
if (!property_exists($serverSettings, $settingName)) {
|
if (!property_exists($serverSettings, $settingName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$oldType = gettype($serverSettings->$settingName);
|
$settingValue = $row->settingValue;
|
||||||
$serverSettings->$settingName = $row->settingValue;
|
settype($settingValue, gettype($serverSettings->$settingName));
|
||||||
settype($serverSettings->$settingName, $oldType);
|
$savedSettings[$settingName] = $settingValue;
|
||||||
$applySettings = true;
|
|
||||||
}
|
}
|
||||||
$result->free();
|
$result->free();
|
||||||
if (!$applySettings) {
|
if (empty($savedSettings)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->client->setServerOptions($serverSettings);
|
$serverOptions = ServerOptions::fromArray($savedSettings);
|
||||||
|
$success = $this->maniaControl->client->setServerOptions($serverOptions);
|
||||||
} catch (ServerOptionsException $exception) {
|
} catch (ServerOptionsException $exception) {
|
||||||
$this->maniaControl->chat->sendExceptionToAdmins($exception);
|
$this->maniaControl->chat->sendExceptionToAdmins($exception);
|
||||||
}
|
}
|
||||||
return true;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user