From bdd82192bb35b5fc2ec92f80f710431b62033682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Mon, 25 Aug 2014 18:01:48 +0200 Subject: [PATCH] fixed missing 'shutdown' message --- application/core/ErrorHandler.php | 20 -------------------- application/core/ManiaControl.php | 22 ++++++++++++++++++++-- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/application/core/ErrorHandler.php b/application/core/ErrorHandler.php index ce6842d7..19c65408 100644 --- a/application/core/ErrorHandler.php +++ b/application/core/ErrorHandler.php @@ -390,26 +390,6 @@ class ErrorHandler { * Handle PHP Process Shutdown */ public function handleShutdown() { - // TODO: skip client-related actions on transport exception (e.g. server down) - - if ($this->maniaControl->getCallbackManager()) { - // OnShutdown callback - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSHUTDOWN); - } - - if ($this->maniaControl->getChat()) { - // Announce quit - $this->maniaControl->getChat()->sendInformation('ManiaControl shutting down.'); - } - - if ($this->maniaControl->getClient()) { - try { - $this->maniaControl->getClient()->sendHideManialinkPage(); - } catch (TransportException $e) { - $this->handleException($e, false); - } - } - // Check if the Shutdown was caused by a Fatal Error and report it $error = error_get_last(); if ($error && self::isFatalError($error['type'])) { diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 5138124c..bcbef952 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -211,8 +211,27 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { * @param bool $errorPrefix */ public function quit($message = null, $errorPrefix = false) { + if ($this->getCallbackManager()) { + // OnShutdown callback + $this->getCallbackManager()->triggerCallback(Callbacks::ONSHUTDOWN); + } + + if ($this->getChat()) { + // Announce quit + $this->getChat()->sendInformation('ManiaControl shutting down.'); + } + + if ($this->getClient()) { + try { + $this->getClient()->sendHideManialinkPage(); + } catch (TransportException $e) { + $this->getErrorHandler()->handleException($e, false); + } + } + Connection::delete($this->getClient()); $this->client = null; + SystemUtil::quit($message, $errorPrefix); } @@ -451,8 +470,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { * @param Player $player */ public function commandShutdown(array $chat, Player $player) { - if (!$this->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_SHUTDOWN) - ) { + if (!$this->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_SHUTDOWN)) { $this->getAuthenticationManager()->sendNotAllowed($player); return; }