fixes for mysql 5.7 support

This commit is contained in:
kremsy 2017-03-09 21:02:03 +01:00
parent de2e9cae84
commit cebdb05027
3 changed files with 48 additions and 8 deletions

View File

@ -81,8 +81,8 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_SCRIPT_SETTINGS . "` ( $query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_SCRIPT_SETTINGS . "` (
`index` int(11) NOT NULL AUTO_INCREMENT, `index` int(11) NOT NULL AUTO_INCREMENT,
`serverIndex` int(11) NOT NULL, `serverIndex` int(11) NOT NULL,
`settingName` varchar(100) NOT NULL, `settingName` varchar(100) NOT NULL DEFAULT '',
`settingValue` varchar(500) NOT NULL, `settingValue` varchar(500) NOT NULL DEFAULT '',
PRIMARY KEY (`index`), PRIMARY KEY (`index`),
UNIQUE KEY `setting` (`serverIndex`, `settingName`) UNIQUE KEY `setting` (`serverIndex`, `settingName`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Script Settings' AUTO_INCREMENT=1;"; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Script Settings' AUTO_INCREMENT=1;";
@ -97,12 +97,29 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
trigger_error($statement->error, E_USER_ERROR); trigger_error($statement->error, E_USER_ERROR);
return false; return false;
} }
//TODO remove later again (added in v0.165)
//For Mysql 5.7 add Default Values
$alterQuery = "ALTER TABLE `" . self::TABLE_SCRIPT_SETTINGS . "` CHANGE settingName settingName varchar(100) DEFAULT ''";
$result = $mysqli->query($alterQuery);
if (!$result) {
trigger_error($mysqli->error);
return false;
}
$alterQuery = "ALTER TABLE `" . self::TABLE_SCRIPT_SETTINGS . "` CHANGE settingValue settingValue varchar(500) DEFAULT ''";
$result = $mysqli->query($alterQuery);
if (!$result) {
trigger_error($mysqli->error);
return false;
}
$statement->close(); $statement->close();
return true; return true;
} }
/** /**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() * @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle()
*/ */
public static function getTitle() { public static function getTitle() {
return 'Script Settings'; return 'Script Settings';
@ -163,7 +180,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
} }
/** /**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu() * @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
*/ */
public function getMenu($width, $height, Script $script, Player $player) { public function getMenu($width, $height, Script $script, Player $player) {
$paging = new Paging(); $paging = new Paging();
@ -286,7 +303,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio
} }
/** /**
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData() * @see \ManiaControl\Configurator\ConfiguratorMenu::saveConfigData()
*/ */
public function saveConfigData(array $configData, Player $player) { public function saveConfigData(array $configData, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS)) { if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS)) {

View File

@ -47,7 +47,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener,
/* /*
* Constants * Constants
*/ */
const VERSION = '0.164'; const VERSION = '0.165';
const API_VERSION = '2013-04-16'; const API_VERSION = '2013-04-16';
const MIN_DEDIVERSION = '2014-04-02_18_00'; const MIN_DEDIVERSION = '2014-04-02_18_00';
const SCRIPT_TIMEOUT = 10; const SCRIPT_TIMEOUT = 10;

View File

@ -144,6 +144,30 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
$playerTableStatement->close(); $playerTableStatement->close();
return false; return false;
} }
//TODO remove later again (added in v0.165)
//For Mysql 5.7 add Default Values
$alterQuery = "ALTER TABLE `" . self::TABLE_PLAYERS . "` CHANGE nickname nickname varchar(150) DEFAULT ''";
$result = $mysqli->query($alterQuery);
if (!$result) {
trigger_error($mysqli->error);
return false;
}
$alterQuery = "ALTER TABLE `" . self::TABLE_PLAYERS . "` CHANGE path path varchar(100) DEFAULT ''";
$result = $mysqli->query($alterQuery);
if (!$result) {
trigger_error($mysqli->error);
return false;
}
$alterQuery = "ALTER TABLE `" . self::TABLE_PLAYERS . "` CHANGE authLevel authLevel int(11) DEFAULT 0";
$result = $mysqli->query($alterQuery);
if (!$result) {
trigger_error($mysqli->error);
return false;
}
$playerTableStatement->close(); $playerTableStatement->close();
return true; return true;
} }
@ -444,8 +468,7 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
//Check if Player finished joining the game //Check if Player finished joining the game
if ($player->hasJoinedGame && !$prevJoinState) { if ($player->hasJoinedGame && !$prevJoinState) {
if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer() if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
) {
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0SuperAdmin', 4 => '$0f0MasterAdmin'); $string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0SuperAdmin', 4 => '$0f0MasterAdmin');
$chatMessage = '$0f0' . $string[$player->authLevel] . ' $<$fff' . $player->nickname . '$> Nation: $<$fff' . $player->getCountry() . '$> joined!'; $chatMessage = '$0f0' . $string[$player->authLevel] . ' $<$fff' . $player->nickname . '$> Nation: $<$fff' . $player->getCountry() . '$> joined!';
$this->maniaControl->getChat()->sendChat($chatMessage); $this->maniaControl->getChat()->sendChat($chatMessage);