fix setting list on mysql

This commit is contained in:
Beu
2025-11-08 22:52:42 +01:00
parent 64832d41e3
commit 53c5e54a3b

View File

@@ -653,11 +653,21 @@ class SettingManager implements CallbackListener, UsageInformationAble {
$className = ClassUtil::getClass($object); $className = ClassUtil::getClass($object);
$mysqli = $this->maniaControl->getDatabase()->getMysqli(); $mysqli = $this->maniaControl->getDatabase()->getMysqli();
// LIMIT is required to keep unlinked setting // LIMIT is required to keep unlinked setting
$settingStatement = $mysqli->prepare("SELECT * FROM (SELECT * FROM `" . self::TABLE_SETTINGS . "`
WHERE class = ? AND (`serverIndex` = ? OR `serverIndex` = 0) $settingStatement = $mysqli->prepare("
ORDER BY `serverIndex` DESC SELECT s.*
LIMIT 9999999) FROM `" . self::TABLE_SETTINGS . "` AS s
as t GROUP BY `setting` ORDER BY `priority` ASC, `setting`;"); JOIN (
SELECT setting, MAX(serverIndex) AS maxServerIndex
FROM `" . self::TABLE_SETTINGS . "`
WHERE class = ? AND (serverIndex = ? OR serverIndex = 0)
GROUP BY setting
) AS x
ON s.setting = x.setting AND s.serverIndex = x.maxServerIndex
WHERE s.class = ? AND (s.serverIndex = ? OR s.serverIndex = 0)
ORDER BY s.priority ASC, s.setting;
");
if ($mysqli->error) { if ($mysqli->error) {
trigger_error($mysqli->error); trigger_error($mysqli->error);
return null; return null;
@@ -668,7 +678,7 @@ class SettingManager implements CallbackListener, UsageInformationAble {
} else { } else {
$serverIndex = $serverInfo->index; $serverIndex = $serverInfo->index;
} }
$settingStatement->bind_param('si', $className, $serverIndex); $settingStatement->bind_param('sisi', $className, $serverIndex, $className, $serverIndex);
if (!$settingStatement->execute()) { if (!$settingStatement->execute()) {
trigger_error('Error executing MySQL query: ' . $settingStatement->error); trigger_error('Error executing MySQL query: ' . $settingStatement->error);
} }