From cfa50168b34e12fdc8da8d996326f7d74d52f357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sun, 4 May 2014 15:09:11 +0200 Subject: [PATCH] update manager fix --- application/core/Update/UpdateManager.php | 36 +++++++++-------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/application/core/Update/UpdateManager.php b/application/core/Update/UpdateManager.php index 785a6def..e4a89cf2 100644 --- a/application/core/Update/UpdateManager.php +++ b/application/core/Update/UpdateManager.php @@ -37,16 +37,16 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener /* * Public Properties */ + /** @var PluginUpdateManager $pluginUpdateManager */ public $pluginUpdateManager = null; + /** @var UpdateData $coreUpdateData */ + public $coreUpdateData = null; /* * Private Properties */ + /** @var ManiaControl $maniaControl */ private $maniaControl = null; - /** - * @var UpdateData $coreUpdateData - */ - private $coreUpdateData = null; private $currentBuildDate = null; /** @@ -85,7 +85,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener /** * Perform Hourly Update Check * - * @param $time + * @param float $time */ public function hourlyUpdateCheck($time) { $updateCheckEnabled = $this->maniaControl->settingManager->getSetting($this, self::SETTING_ENABLEUPDATECHECK); @@ -117,7 +117,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener * * @param callable $function */ - private function checkCoreUpdateAsync($function) { + public function checkCoreUpdateAsync($function) { $updateChannel = $this->getCurrentUpdateChannelSetting(); $url = ManiaControl::URL_WEBSERVICE . 'versions?current=1&channel=' . $updateChannel; @@ -137,7 +137,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener * * @return string */ - private function getCurrentUpdateChannelSetting() { + public function getCurrentUpdateChannelSetting() { $updateChannel = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_CHANNEL); $updateChannel = strtolower($updateChannel); if (!in_array($updateChannel, array(self::CHANNEL_RELEASE, self::CHANNEL_BETA, self::CHANNEL_NIGHTLY))) { @@ -270,7 +270,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener * @param Player $player * @return bool */ - private function performCoreUpdate(Player $player = null) { + public function performCoreUpdate(Player $player = null) { if (!$this->coreUpdateData) { $message = 'Update failed: No update Data available!'; if ($player) { @@ -361,7 +361,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener * @param string $date * @return bool */ - private function setNightlyBuildDate($date) { + public function setNightlyBuildDate($date) { $nightlyBuildDateFile = ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'nightly_build.txt'; $success = (bool)file_put_contents($nightlyBuildDateFile, $date); $this->currentBuildDate = $date; @@ -453,26 +453,18 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener } $self = $this; - $this->checkCoreUpdateAsync(function (UpdateData $updateData = null) use (&$self, &$player) { + $maniaControl = $this->maniaControl; + $this->checkCoreUpdateAsync(function (UpdateData $updateData = null) use (&$self, &$maniaControl, &$player) { if (!$updateData) { - $self->maniaControl->chat->sendError('Update is currently not possible!', $player->login); + $maniaControl->chat->sendError('Update is currently not possible!', $player); return; } if (!$self->checkUpdateDataBuildVersion($updateData)) { - $self->maniaControl->chat->sendError("The Next ManiaControl Update requires a newer Dedicated Server Version!", $player->login); + $maniaControl->chat->sendError("The Next ManiaControl Update requires a newer Dedicated Server Version!", $player); return; } - $message = "Starting Update to Version v{$updateData->version}..."; - $self->maniaControl->chat->sendInformation($message, $player->login); - $self->maniaControl->log($message); - - $performBackup = $self->maniaControl->settingManager->getSetting($self, UpdateManager::SETTING_PERFORM_BACKUPS); - if ($performBackup && !BackupUtil::performFullBackup()) { - $message = 'Creating Backup failed!'; - $self->maniaControl->chat->sendError($message, $player->login); - $self->maniaControl->log($message); - } + $self->coreUpdateData = $updateData; $self->performCoreUpdate($player); });