Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #4711 Adding new console command to trigger Piwik core and Plug…
…ins upgrades, if any. Run it via: ./console core:update --dry-run
- Loading branch information
Showing
10 changed files
with
152 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* Piwik - Open source web analytics | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
namespace Piwik\Plugins\CoreUpdater\Commands; | ||
|
||
use Piwik\Plugin\ConsoleCommand; | ||
use Piwik\Plugins\CoreUpdater\Controller; | ||
use Piwik\Plugins\CoreUpdater\NoUpdatesFoundException; | ||
use Piwik\Plugins\UserCountry\LocationProvider; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputDefinition; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* @package CloudAdmin | ||
*/ | ||
class Update extends ConsoleCommand | ||
{ | ||
protected function configure() | ||
{ | ||
$this->setName('core:update'); | ||
$this->setDescription('Triggers the upgrades for Piwik core and plugins. Useful after Piwik core files or some plugins were updated to latest files.'); | ||
|
||
$this->addOption('dry-run', null, InputOption::VALUE_NONE, 'Only prints out the SQL requests that would be executed during the upgrade'); | ||
} | ||
|
||
/** | ||
* Execute command like: ./console core:update --dry-run | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$doDryRun = $input->getOption('dry-run'); | ||
|
||
try { | ||
$this->makeUpdate($input, $output, $doDryRun); | ||
} catch(NoUpdatesFoundException $e) { | ||
// Do not fail if no updates were found | ||
$output->writeln("<info>".$e->getMessage()."</info>"); | ||
} catch (\Exception $e) { | ||
// Fail in case of any other error during upgrade | ||
$output->writeln("<error>" . $e->getMessage() . "</error>"); | ||
throw $e; | ||
} | ||
} | ||
|
||
protected function makeUpdate(InputInterface $input, OutputInterface $output, $doDryRun) | ||
{ | ||
$this->checkAllRequiredOptionsAreNotEmpty($input); | ||
|
||
$updateController = new Controller(); | ||
echo $updateController->runUpdaterAndExit($doDryRun); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
/** | ||
* Piwik - Open source web analytics | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
namespace Piwik\Plugins\CoreUpdater; | ||
|
||
class NoUpdatesFoundException extends \Exception { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters