Merge pull request #19677 from owncloud/silently-fail-app-upgrade-exceptions-master
Silently fail app upgrade exceptions
This commit is contained in:
commit
3891cd9068
|
@ -30,6 +30,7 @@ namespace OC\Core\Command;
|
|||
use OC\Console\TimestampFormatter;
|
||||
use OC\Updater;
|
||||
use OCP\IConfig;
|
||||
use OCP\ILogger;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
@ -44,17 +45,19 @@ class Upgrade extends Command {
|
|||
const ERROR_INVALID_ARGUMENTS = 4;
|
||||
const ERROR_FAILURE = 5;
|
||||
|
||||
/**
|
||||
* @var IConfig
|
||||
*/
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/** @var ILogger */
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
public function __construct(IConfig $config, ILogger $logger) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
|
@ -126,7 +129,8 @@ class Upgrade extends Command {
|
|||
|
||||
$self = $this;
|
||||
$updater = new Updater(\OC::$server->getHTTPHelper(),
|
||||
$this->config);
|
||||
$this->config,
|
||||
$this->logger);
|
||||
|
||||
$updater->setSimulateStepEnabled($simulateStepEnabled);
|
||||
$updater->setUpdateStepEnabled($updateStepEnabled);
|
||||
|
|
|
@ -94,7 +94,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
|
|||
$application->add(new OC\Core\Command\Maintenance\Repair(new \OC\Repair(\OC\Repair::getRepairSteps()), \OC::$server->getConfig()));
|
||||
$application->add(new OC\Core\Command\Maintenance\SingleUser(\OC::$server->getConfig()));
|
||||
|
||||
$application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig()));
|
||||
$application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger()));
|
||||
|
||||
$application->add(new OC\Core\Command\User\Add(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
|
||||
$application->add(new OC\Core\Command\User\Delete(\OC::$server->getUserManager()));
|
||||
|
|
|
@ -79,7 +79,7 @@ class OC_TemplateLayout extends OC_Template {
|
|||
if($this->config->getSystemValue('updatechecker', true) === true &&
|
||||
OC_User::isAdminUser(OC_User::getUser())) {
|
||||
$updater = new \OC\Updater(\OC::$server->getHTTPHelper(),
|
||||
\OC::$server->getConfig());
|
||||
\OC::$server->getConfig(), \OC::$server->getLogger());
|
||||
$data = $updater->check();
|
||||
|
||||
if(isset($data['version']) && $data['version'] != '' and $data['version'] !== Array()) {
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
namespace OC;
|
||||
|
||||
use OC\Core\Command\Log\Manage;
|
||||
use OC\Hooks\BasicEmitter;
|
||||
use OC_App;
|
||||
use OC_Installer;
|
||||
|
@ -199,15 +198,13 @@ class Updater extends BasicEmitter {
|
|||
|
||||
$installedVersion = $this->config->getSystemValue('version', '0.0.0');
|
||||
$currentVersion = implode('.', \OC_Util::getVersion());
|
||||
if ($this->log) {
|
||||
$this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
|
||||
}
|
||||
|
||||
$success = true;
|
||||
try {
|
||||
$this->doUpgrade($currentVersion, $installedVersion);
|
||||
} catch (\Exception $exception) {
|
||||
\OCP\Util::logException('update', $exception);
|
||||
$this->log->logException($exception, ['app' => 'core']);
|
||||
$this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage()));
|
||||
$success = false;
|
||||
}
|
||||
|
@ -235,6 +232,7 @@ class Updater extends BasicEmitter {
|
|||
private function getAllowedPreviousVersion() {
|
||||
// this should really be a JSON file
|
||||
require \OC::$SERVERROOT . '/version.php';
|
||||
/** @var array $OC_VersionCanBeUpgradedFrom */
|
||||
return implode('.', $OC_VersionCanBeUpgradedFrom);
|
||||
}
|
||||
|
||||
|
@ -497,12 +495,16 @@ class Updater extends BasicEmitter {
|
|||
*/
|
||||
private function upgradeAppStoreApps(array $disabledApps) {
|
||||
foreach($disabledApps as $app) {
|
||||
try {
|
||||
if (OC_Installer::isUpdateAvailable($app)) {
|
||||
$ocsId = \OC::$server->getConfig()->getAppValue($app, 'ocsid', '');
|
||||
|
||||
$this->emit('\OC\Updater', 'upgradeAppStoreApp', array($app));
|
||||
OC_Installer::updateAppByOCSId($ocsId);
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$this->log->logException($ex, ['app' => 'core']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ class UpdaterTest extends \Test\TestCase {
|
|||
* @param bool $result
|
||||
*/
|
||||
public function testIsUpgradePossible($oldVersion, $newVersion, $allowedVersion, $result) {
|
||||
$updater = new Updater($this->httpHelper, $this->config);
|
||||
$updater = new Updater($this->httpHelper, $this->config, $this->logger);
|
||||
$this->assertSame($result, $updater->isUpgradePossible($oldVersion, $newVersion, $allowedVersion));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue