protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->repair->listen('\\OC\\Repair', 'step', function ($description) use($output) {
         $output->writeln(' - ' . $description);
     });
     $this->repair->run();
 }
 /**
  * @param array $argument
  * @throws \Exception
  * @throws \OC\NeedsUpdateException
  */
 protected function run($argument)
 {
     if (!isset($argument['app']) || !isset($argument['step'])) {
         // remove the job - we can never execute it
         $this->jobList->remove($this, $this->argument);
         return;
     }
     $app = $argument['app'];
     try {
         $this->loadApp($app);
     } catch (NeedsUpdateException $ex) {
         // as long as the app is not yet done with it's offline migration
         // we better not start with the live migration
         return;
     }
     $step = $argument['step'];
     $repair = new Repair([], $this->dispatcher);
     try {
         $repair->addStep($step);
     } catch (\Exception $ex) {
         $this->logger->logException($ex, ['app' => 'migration']);
         // remove the job - we can never execute it
         $this->jobList->remove($this, $this->argument);
         return;
     }
     // execute the repair step
     $repair->run();
     // remove the job once executed successfully
     $this->jobList->remove($this, $this->argument);
 }
Exemple #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $includeExpensive = $input->getOption('include-expensive');
     if ($includeExpensive) {
         foreach ($this->repair->getExpensiveRepairSteps() as $step) {
             $this->repair->addStep($step);
         }
     }
     $maintenanceMode = $this->config->getSystemValue('maintenance', false);
     $this->config->setSystemValue('maintenance', true);
     $this->repair->listen('\\OC\\Repair', 'step', function ($description) use($output) {
         $output->writeln(' - ' . $description);
     });
     $this->repair->listen('\\OC\\Repair', 'info', function ($description) use($output) {
         $output->writeln('     - ' . $description);
     });
     $this->repair->listen('\\OC\\Repair', 'warning', function ($description) use($output) {
         $output->writeln('     - WARNING: ' . $description);
     });
     $this->repair->listen('\\OC\\Repair', 'error', function ($description) use($output) {
         $output->writeln('     - ERROR: ' . $description);
     });
     $this->repair->run();
     $this->config->setSystemValue('maintenance', $maintenanceMode);
 }
 public function testRunRepairStepsContinueAfterWarning()
 {
     $this->repair->addStep(new TestRepairStep(true));
     $this->repair->addStep(new TestRepairStep(false));
     $this->repair->run();
     $this->assertEquals(array('step: Test Name', 'warning: Simulated warning', 'step: Test Name', 'info: Simulated info'), $this->outputArray);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $maintenanceMode = $this->config->getSystemValue('maintenance', false);
     $this->config->setSystemValue('maintenance', true);
     $this->repair->listen('\\OC\\Repair', 'step', function ($description) use($output) {
         $output->writeln(' - ' . $description);
     });
     $this->repair->listen('\\OC\\Repair', 'info', function ($description) use($output) {
         $output->writeln('     - ' . $description);
     });
     $this->repair->listen('\\OC\\Repair', 'error', function ($description) use($output) {
         $output->writeln('     - ERROR: ' . $description);
     });
     $this->repair->run();
     $this->config->setSystemValue('maintenance', $maintenanceMode);
 }
Exemple #6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // TODO: inject DB connection/factory when possible
     $connection = \OC_DB::getConnection();
     $connection->disableQueryStatementCaching();
     $maintenanceMode = $this->config->getValue('maintenance', false);
     $this->config->setValue('maintenance', true);
     $this->repair->listen('\\OC\\Repair', 'step', function ($description) use($output) {
         $output->writeln(' - ' . $description);
     });
     $this->repair->listen('\\OC\\Repair', 'info', function ($description) use($output) {
         $output->writeln('     - ' . $description);
     });
     $this->repair->listen('\\OC\\Repair', 'error', function ($description) use($output) {
         $output->writeln('     - ERROR: ' . $description);
     });
     $this->repair->run();
     $this->config->setValue('maintenance', $maintenanceMode);
 }
Exemple #7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $includeExpensive = $input->getOption('include-expensive');
     if ($includeExpensive) {
         foreach ($this->repair->getExpensiveRepairSteps() as $step) {
             $this->repair->addStep($step);
         }
     }
     $apps = \OC::$server->getAppManager()->getInstalledApps();
     foreach ($apps as $app) {
         if (!\OC_App::isEnabled($app)) {
             continue;
         }
         $info = \OC_App::getAppInfo($app);
         if (!is_array($info)) {
             continue;
         }
         $steps = $info['repair-steps']['post-migration'];
         foreach ($steps as $step) {
             try {
                 $this->repair->addStep($step);
             } catch (Exception $ex) {
                 $output->writeln("<error>Failed to load repair step for {$app}: {$ex->getMessage()}</error>");
             }
         }
     }
     $maintenanceMode = $this->config->getSystemValue('maintenance', false);
     $this->config->setSystemValue('maintenance', true);
     $this->progress = new ProgressBar($output);
     $this->output = $output;
     $this->dispatcher->addListener('\\OC\\Repair::startProgress', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::advance', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::finishProgress', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::step', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::info', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::warning', [$this, 'handleRepairFeedBack']);
     $this->dispatcher->addListener('\\OC\\Repair::error', [$this, 'handleRepairFeedBack']);
     $this->repair->run();
     $this->config->setSystemValue('maintenance', $maintenanceMode);
 }
Exemple #8
0
 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  * except the main .htaccess file
  *
  * @param string $currentVersion current version to upgrade to
  * @param string $installedVersion previous version from which to upgrade from
  *
  * @throws \Exception
  * @return bool true if the operation succeeded, false otherwise
  */
 private function doUpgrade($currentVersion, $installedVersion)
 {
     // Stop update if the update is over several major versions
     if (!self::isUpgradePossible($installedVersion, $currentVersion)) {
         throw new \Exception('Updates between multiple major versions are unsupported.');
     }
     // Update htaccess files for apache hosts
     if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
         \OC_Setup::updateHtaccess();
     }
     // create empty file in data dir, so we can later find
     // out that this is indeed an ownCloud data directory
     // (in case it didn't exist before)
     file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
     /*
      * START CONFIG CHANGES FOR OLDER VERSIONS
      */
     if (!\OC::$CLI && version_compare($installedVersion, '6.90.1', '<')) {
         // Add the trusted_domains config if it is not existant
         // This is added to prevent host header poisoning
         \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost())));
     }
     /*
      * STOP CONFIG CHANGES FOR OLDER VERSIONS
      */
     // pre-upgrade repairs
     $repair = new \OC\Repair(\OC\Repair::getBeforeUpgradeRepairSteps());
     $repair->run();
     // simulate DB upgrade
     if ($this->simulateStepEnabled) {
         $this->checkCoreUpgrade();
         // simulate apps DB upgrade
         $this->checkAppUpgrade($currentVersion);
     }
     // upgrade from OC6 to OC7
     // TODO removed it again for OC8
     $sharePolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
     if ($sharePolicy === 'groups_only') {
         \OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', 'yes');
     }
     if ($this->updateStepEnabled) {
         $this->doCoreUpgrade();
         $disabledApps = \OC_App::checkAppsRequirements();
         if (!empty($disabledApps)) {
             $this->emit('\\OC\\Updater', 'disabledApps', array($disabledApps));
         }
         $this->doAppUpgrade();
         // post-upgrade repairs
         $repair = new \OC\Repair(\OC\Repair::getRepairSteps());
         $repair->run();
         //Invalidate update feed
         \OC_Appconfig::setValue('core', 'lastupdatedat', 0);
         // only set the final version if everything went well
         \OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
     }
 }
Exemple #9
0
	/**
	 * runs the update actions in maintenance mode, does not upgrade the source files
	 * except the main .htaccess file
	 *
	 * @param string $currentVersion current version to upgrade to
	 * @param string $installedVersion previous version from which to upgrade from
	 *
	 * @throws \Exception
	 * @return bool true if the operation succeeded, false otherwise
	 */
	private function doUpgrade($currentVersion, $installedVersion) {
		// Stop update if the update is over several major versions
		if (!self::isUpgradePossible($installedVersion, $currentVersion)) {
			throw new \Exception('Updates between multiple major versions are unsupported.');
		}

		// Update .htaccess files
		try {
			Setup::updateHtaccess();
			Setup::protectDataDirectory();
		} catch (\Exception $e) {
			throw new \Exception($e->getMessage());
		}

		// create empty file in data dir, so we can later find
		// out that this is indeed an ownCloud data directory
		// (in case it didn't exist before)
		file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');

		// pre-upgrade repairs
		$repair = new Repair(Repair::getBeforeUpgradeRepairSteps());
		$this->emitRepairMessages($repair);
		$repair->run();

		// simulate DB upgrade
		if ($this->simulateStepEnabled) {
			$this->checkCoreUpgrade();

			// simulate apps DB upgrade
			$this->checkAppUpgrade($currentVersion);

		}

		if ($this->updateStepEnabled) {
			$this->doCoreUpgrade();

			// update all shipped apps
			$disabledApps = $this->checkAppsRequirements();
			$this->doAppUpgrade();

			// upgrade appstore apps
			$this->upgradeAppStoreApps($disabledApps);


			// post-upgrade repairs
			$repair = new Repair(Repair::getRepairSteps());
			$this->emitRepairMessages($repair);
			$repair->run();

			//Invalidate update feed
			$this->config->setAppValue('core', 'lastupdatedat', 0);

			// only set the final version if everything went well
			$this->config->setSystemValue('version', implode('.', \OC_Util::getVersion()));
		}
	}
    $application->add(new OC\Core\Command\Config\System\GetConfig(\OC::$server->getSystemConfig()));
    $application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->getSystemConfig()));
    $application->add(new OC\Core\Command\Db\GenerateChangeScript());
    $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory()));
    $application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig()));
    $application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager()));
    $application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager()));
    $application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager()));
    $application->add(new OC\Core\Command\Encryption\Status(\OC::$server->getEncryptionManager()));
    $application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper()));
    $application->add(new OC\Core\Command\Encryption\DecryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \OC\Encryption\DecryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getUserManager(), new \OC\Files\View()), new \Symfony\Component\Console\Helper\QuestionHelper()));
    $application->add(new OC\Core\Command\Log\Manage(\OC::$server->getConfig()));
    $application->add(new OC\Core\Command\Log\OwnCloud(\OC::$server->getConfig()));
    $view = new \OC\Files\View();
    $util = new \OC\Encryption\Util($view, \OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->getConfig());
    $application->add(new OC\Core\Command\Encryption\ChangeKeyStorageRoot($view, \OC::$server->getUserManager(), \OC::$server->getConfig(), $util, new \Symfony\Component\Console\Helper\QuestionHelper()));
    $application->add(new OC\Core\Command\Encryption\ShowKeyStorageRoot($util));
    $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->getMimeTypeLoader()));
    $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector()));
    $application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig()));
    $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(), \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()));
    $application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager()));
    $application->add(new OC\Core\Command\User\Report(\OC::$server->getUserManager()));
    $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager()));
} else {
    $application->add(new OC\Core\Command\Maintenance\Install(\OC::$server->getConfig()));
}
Exemple #11
0
	/**
	 * runs the update actions in maintenance mode, does not upgrade the source files
	 * except the main .htaccess file
	 *
	 * @param string $currentVersion current version to upgrade to
	 * @param string $installedVersion previous version from which to upgrade from
	 *
	 * @throws \Exception
	 * @return bool true if the operation succeeded, false otherwise
	 */
	private function doUpgrade($currentVersion, $installedVersion) {
		// Stop update if the update is over several major versions
		if (!self::isUpgradePossible($installedVersion, $currentVersion)) {
			throw new \Exception('Updates between multiple major versions are unsupported.');
		}

		// Update htaccess files for apache hosts
		if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
			try {
				\OC_Setup::updateHtaccess();
			} catch (\Exception $e) {
				throw new \Exception($e->getMessage());
			}
		}

		// create empty file in data dir, so we can later find
		// out that this is indeed an ownCloud data directory
		// (in case it didn't exist before)
		file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');

		// pre-upgrade repairs
		$repair = new \OC\Repair(\OC\Repair::getBeforeUpgradeRepairSteps());
		$repair->run();

		// simulate DB upgrade
		if ($this->simulateStepEnabled) {
			$this->checkCoreUpgrade();

			// simulate apps DB upgrade
			$this->checkAppUpgrade($currentVersion);

		}

		if ($this->updateStepEnabled) {
			$this->doCoreUpgrade();

			$disabledApps = \OC_App::checkAppsRequirements();
			if (!empty($disabledApps)) {
				$this->emit('\OC\Updater', 'disabledApps', array($disabledApps));
			}

			$this->doAppUpgrade();

			// post-upgrade repairs
			$repair = new \OC\Repair(\OC\Repair::getRepairSteps());
			$repair->run();

			//Invalidate update feed
			$this->config->setValue('core', 'lastupdatedat', 0);

			// only set the final version if everything went well
			\OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
		}
	}
Exemple #12
0
 /**
  * @param string $appId
  * @param string[] $steps
  * @throws \OC\NeedsUpdateException
  */
 public static function executeRepairSteps($appId, array $steps)
 {
     if (empty($steps)) {
         return;
     }
     // load the app
     self::loadApp($appId, false);
     $dispatcher = OC::$server->getEventDispatcher();
     // load the steps
     $r = new Repair([], $dispatcher);
     foreach ($steps as $step) {
         try {
             $r->addStep($step);
         } catch (Exception $ex) {
             $r->emit('\\OC\\Repair', 'error', [$ex->getMessage()]);
             \OC::$server->getLogger()->logException($ex);
         }
     }
     // run the steps
     $r->run();
 }
Exemple #13
0
 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  * except the main .htaccess file
  *
  * @param string $currentVersion current version to upgrade to
  * @param string $installedVersion previous version from which to upgrade from
  *
  * @return bool true if the operation succeeded, false otherwise
  */
 private function doUpgrade($currentVersion, $installedVersion)
 {
     // Update htaccess files for apache hosts
     if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) {
         \OC_Setup::updateHtaccess();
     }
     // create empty file in data dir, so we can later find
     // out that this is indeed an ownCloud data directory
     // (in case it didn't exist before)
     file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
     /*
      * START CONFIG CHANGES FOR OLDER VERSIONS
      */
     if (!\OC::$CLI && version_compare($installedVersion, '6.90.1', '<')) {
         // Add the trusted_domains config if it is not existant
         // This is added to prevent host header poisoning
         \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost())));
     }
     /*
      * STOP CONFIG CHANGES FOR OLDER VERSIONS
      */
     // pre-upgrade repairs
     $repair = new \OC\Repair(\OC\Repair::getBeforeUpgradeRepairSteps());
     $repair->run();
     // simulate DB upgrade
     if ($this->simulateStepEnabled) {
         // simulate core DB upgrade
         \OC_DB::simulateUpdateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
         // simulate apps DB upgrade
         $version = \OC_Util::getVersion();
         $apps = \OC_App::getEnabledApps();
         foreach ($apps as $appId) {
             $info = \OC_App::getAppInfo($appId);
             if (\OC_App::isAppCompatible($version, $info) && \OC_App::shouldUpgrade($appId)) {
                 if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) {
                     \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml');
                 }
             }
         }
         $this->emit('\\OC\\Updater', 'dbSimulateUpgrade');
     }
     // upgrade from OC6 to OC7
     // TODO removed it again for OC8
     $sharePolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
     if ($sharePolicy === 'groups_only') {
         \OC_Appconfig::setValue('core', 'shareapi_only_share_with_group_members', 'yes');
     }
     if ($this->updateStepEnabled) {
         // do the real upgrade
         \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
         $this->emit('\\OC\\Updater', 'dbUpgrade');
         // TODO: why not do this at the end ?
         \OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
         $disabledApps = \OC_App::checkAppsRequirements();
         if (!empty($disabledApps)) {
             $this->emit('\\OC\\Updater', 'disabledApps', array($disabledApps));
         }
         // load all apps to also upgrade enabled apps
         \OC_App::loadApps();
         // post-upgrade repairs
         $repair = new \OC\Repair(\OC\Repair::getRepairSteps());
         $repair->run();
         //Invalidate update feed
         \OC_Appconfig::setValue('core', 'lastupdatedat', 0);
     }
 }
Exemple #14
0
 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  */
 public function upgrade()
 {
     \OC_DB::enableCaching(false);
     \OC_Config::setValue('maintenance', true);
     $installedVersion = \OC_Config::getValue('version', '0.0.0');
     $currentVersion = implode('.', \OC_Util::getVersion());
     if ($this->log) {
         $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
     }
     $this->emit('\\OC\\Updater', 'maintenanceStart');
     // create empty file in data dir, so we can later find
     // out that this is indeed an ownCloud data directory
     // (in case it didn't exist before)
     file_put_contents(\OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
     /*
      * START CONFIG CHANGES FOR OLDER VERSIONS
      */
     if (!\OC::$CLI && version_compare($installedVersion, '6.00.4', '<')) {
         // Add the trusted_domains config if it is not existant
         // This is added to prevent host header poisoning
         \OC_Config::setValue('trusted_domains', \OC_Config::getValue('trusted_domains', array(\OC_Request::serverHost())));
     }
     /*
      * STOP CONFIG CHANGES FOR OLDER VERSIONS
      */
     try {
         \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
         $this->emit('\\OC\\Updater', 'dbUpgrade');
         // do a file cache upgrade for users with files
         // this can take loooooooooooooooooooooooong
         $this->upgradeFileCache();
     } catch (\Exception $exception) {
         $this->emit('\\OC\\Updater', 'failure', array($exception->getMessage()));
     }
     \OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
     \OC_App::checkAppsRequirements();
     // load all apps to also upgrade enabled apps
     \OC_App::loadApps();
     $repair = new Repair();
     $repair->run();
     //Invalidate update feed
     \OC_Appconfig::setValue('core', 'lastupdatedat', 0);
     \OC_Config::setValue('maintenance', false);
     $this->emit('\\OC\\Updater', 'maintenanceEnd');
 }
Exemple #15
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
/** @var $application Symfony\Component\Console\Application */
$application->add(new OC\Core\Command\Status());
$application->add(new OC\Core\Command\Check(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\App\CheckCode());
$application->add(new OC\Core\Command\L10n\CreateJs());
if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
    $repair = new \OC\Repair(\OC\Repair::getRepairSteps());
    $application->add(new OC\Core\Command\Db\GenerateChangeScript());
    $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory()));
    $application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig()));
    $application->add(new OC\Core\Command\Maintenance\SingleUser());
    $application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig()));
    $application->add(new OC\Core\Command\App\Disable());
    $application->add(new OC\Core\Command\App\Enable());
    $application->add(new OC\Core\Command\App\ListApps());
    $application->add(new OC\Core\Command\Maintenance\Repair($repair, \OC::$server->getConfig()));
    $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()));
    $application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager()));
    $application->add(new OC\Core\Command\User\Report(\OC::$server->getUserManager()));
    $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager()));
    $application->add(new OC\Core\Command\Background\Cron(\OC::$server->getConfig()));
Exemple #16
0
 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  * except the main .htaccess file
  *
  * @param string $currentVersion current version to upgrade to
  * @param string $installedVersion previous version from which to upgrade from
  *
  * @throws \Exception
  */
 private function doUpgrade($currentVersion, $installedVersion)
 {
     // Stop update if the update is over several major versions
     $allowedPreviousVersion = $this->getAllowedPreviousVersion();
     if (!self::isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersion)) {
         throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
     }
     // Update .htaccess files
     try {
         Setup::updateHtaccess();
         Setup::protectDataDirectory();
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage());
     }
     // create empty file in data dir, so we can later find
     // out that this is indeed an ownCloud data directory
     // (in case it didn't exist before)
     file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
     // pre-upgrade repairs
     $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher());
     $repair->run();
     // simulate DB upgrade
     if ($this->simulateStepEnabled) {
         $this->checkCoreUpgrade();
         // simulate apps DB upgrade
         $this->checkAppUpgrade($currentVersion);
     }
     if ($this->updateStepEnabled) {
         $this->doCoreUpgrade();
         // update all shipped apps
         $disabledApps = $this->checkAppsRequirements();
         $this->doAppUpgrade();
         // upgrade appstore apps
         $this->upgradeAppStoreApps($disabledApps);
         // install new shipped apps on upgrade
         OC_App::loadApps('authentication');
         $errors = Installer::installShippedApps(true);
         foreach ($errors as $appId => $exception) {
             /** @var \Exception $exception */
             $this->log->logException($exception, ['app' => $appId]);
             $this->emit('\\OC\\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
         }
         // post-upgrade repairs
         $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher());
         $repair->run();
         //Invalidate update feed
         $this->config->setAppValue('core', 'lastupdatedat', 0);
         // Check for code integrity if not disabled
         if (\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
             $this->emit('\\OC\\Updater', 'startCheckCodeIntegrity');
             $this->checker->runInstanceVerification();
             $this->emit('\\OC\\Updater', 'finishedCheckCodeIntegrity');
         }
         // only set the final version if everything went well
         $this->config->setSystemValue('version', implode('.', \OCP\Util::getVersion()));
     }
 }
 /**
  * runs the update actions in maintenance mode, does not upgrade the source files
  */
 public function upgrade()
 {
     \OC_DB::enableCaching(false);
     \OC_Config::setValue('maintenance', true);
     $installedVersion = \OC_Config::getValue('version', '0.0.0');
     $currentVersion = implode('.', \OC_Util::getVersion());
     if ($this->log) {
         $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
     }
     $this->emit('\\OC\\Updater', 'maintenanceStart');
     try {
         \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml');
         $this->emit('\\OC\\Updater', 'dbUpgrade');
         // do a file cache upgrade for users with files
         // this can take loooooooooooooooooooooooong
         $this->upgradeFileCache();
     } catch (\Exception $exception) {
         $this->emit('\\OC\\Updater', 'failure', array($exception->getMessage()));
     }
     \OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
     \OC_App::checkAppsRequirements();
     // load all apps to also upgrade enabled apps
     \OC_App::loadApps();
     $repair = new Repair();
     $repair->run();
     \OC_Config::setValue('maintenance', false);
     $this->emit('\\OC\\Updater', 'maintenanceEnd');
 }