From d5b8c2aee7921ae437e6718332209f0e4b736881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Muszy=C5=84ski?= Date: Tue, 22 Sep 2015 12:38:11 +0200 Subject: [PATCH] updater wraper improvements --- Manager/UpdateManager.php | 6 ++++-- Manager/Updater.php | 16 ++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Manager/UpdateManager.php b/Manager/UpdateManager.php index 5e2ea52..628b17b 100644 --- a/Manager/UpdateManager.php +++ b/Manager/UpdateManager.php @@ -198,12 +198,14 @@ public function updateCore() )); if ($result !== 0) { - throw new \RuntimeException('Could not update the instance.'); + $this->addLogInfo($result); + + throw new \RuntimeException('Could not update the instance. See logs for more details.'); } $this->addLogInfo('Successfully updated application\'s core...'); - $this->cleanUp($packagePath); + //$this->cleanUp($packagePath); } } diff --git a/Manager/Updater.php b/Manager/Updater.php index 1ded971..49144b8 100644 --- a/Manager/Updater.php +++ b/Manager/Updater.php @@ -11,12 +11,11 @@ * @copyright 2015 Sourcefabric z.รบ. * @license http://www.superdesk.org/license */ - namespace SWP\UpdaterBundle\Manager; use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Output\NullOutput; use Updater\Console\Application; +use Symfony\Component\Console\Output\BufferedOutput; /** * Updater wrapper. @@ -30,11 +29,11 @@ class Updater * * @param array $parameters Command parameters * - * @return string Command output + * @return string|int Command output */ public static function runUpdateCommand(array $parameters = array()) { - $parameters['command'] = self::UPDATE_COMMAND; + $parameters = array('command' => self::UPDATE_COMMAND) + $parameters; return self::runCommand($parameters); } @@ -42,10 +41,15 @@ public static function runUpdateCommand(array $parameters = array()) private static function runCommand(array $parameters = array()) { $input = new ArrayInput($parameters); - $output = new NullOutput(); + $output = new BufferedOutput(); $app = new Application(); $app->setAutoExit(false); - return $app->run($input, $output); + $result = $app->run($input, $output); + if ($result !== 0) { + return $output->fetch(); + } + + return $result; } }