From 46a121d3d9059be5956bd1022c8fdca084c0119d Mon Sep 17 00:00:00 2001 From: Sebastian Schreiber Date: Wed, 31 Oct 2018 17:14:08 +0100 Subject: [PATCH] [HOTFIX] Move instantiation of Updater to execute method Resolve #218 --- src/Command/SelfUpdateCommand.php | 43 ++++++++++--------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/src/Command/SelfUpdateCommand.php b/src/Command/SelfUpdateCommand.php index 2833bc13..344eef08 100755 --- a/src/Command/SelfUpdateCommand.php +++ b/src/Command/SelfUpdateCommand.php @@ -24,27 +24,6 @@ class SelfUpdateCommand extends Command { - /** - * @var Updater - */ - private $updater; - - /** - * SelfUpdateCommand constructor. - * - * @param null $name - */ - public function __construct($name = null) - { - parent::__construct($name); - - $this->updater = new Updater(null, false, Updater::STRATEGY_GITHUB); - /** @var GithubStrategy $strategy */ - $strategy = $this->updater->getStrategy(); - $strategy->setPackageName('TYPO3/Surf'); - $strategy->setPharName('surf.phar'); - } - /** * @return bool */ @@ -85,6 +64,12 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { + $updater = new Updater(null, false, Updater::STRATEGY_GITHUB); + /** @var GithubStrategy $strategy */ + $strategy = $updater->getStrategy(); + $strategy->setPackageName('TYPO3/Surf'); + $strategy->setPharName('surf.phar'); + $io = new SymfonyStyle($input, $output); $stability = $input->getOption('stability'); @@ -93,36 +78,36 @@ protected function execute(InputInterface $input, OutputInterface $output) $stability = GithubStrategy::UNSTABLE; } /** @var GithubStrategy $strategy */ - $strategy = $this->updater->getStrategy(); + $strategy = $updater->getStrategy(); $strategy->setCurrentLocalVersion($this->getApplication()->getVersion()); $strategy->setStability($stability); if ($input->getOption('check')) { - $result = $this->updater->hasUpdate(); + $result = $updater->hasUpdate(); if ($result) { $output->writeln(sprintf( 'The %s build available remotely is: %s', $strategy->getStability() === GithubStrategy::ANY ? 'latest' : 'current ' . $strategy->getStability(), - $this->updater->getNewVersion() + $updater->getNewVersion() )); - } elseif (false === $this->updater->getNewVersion()) { + } elseif (false === $updater->getNewVersion()) { $output->writeln('There are no new builds available.'); } else { $output->writeln(sprintf('You have the current %s build installed.', $strategy->getStability())); } } elseif ($input->getOption('rollback')) { - $result = $this->updater->rollback(); + $result = $updater->rollback(); $result ? $output->writeln('Success!') : $output->writeln('Failure!'); } else { - $result = $this->updater->update(); + $result = $updater->update(); if ($result) { $io->success( sprintf( 'Your %s has been updated from "%s" to "%s".', $this->getLocalPharName(), - $this->updater->getOldVersion(), - $this->updater->getNewVersion() + $updater->getOldVersion(), + $updater->getNewVersion() ) ); } else {