Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

[WIP] updater wrapper improvements #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Manager/UpdateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
16 changes: 10 additions & 6 deletions Manager/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -30,22 +29,27 @@ 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);
}

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;
}
}