protected function execute(InputInterface $input, OutputInterface $output)
 {
     $rc = 0;
     try {
         if (!$input->getOption('force')) {
             if (!$input->isInteractive()) {
                 throw new Exception("You have to specify the --force option in order to run this command");
             }
             $confirmQuestion = new ConfirmationQuestion('Are you sure you want to update this concrete5 installation?');
             if (!$this->getHelper('question')->ask($input, $output, $confirmQuestion)) {
                 throw new Exception("Operation aborted.");
             }
         }
         $configuration = new \Concrete\Core\Updater\Migrations\Configuration();
         $output = new ConsoleOutput();
         $configuration->setOutputWriter(new OutputWriter(function ($message) use($output) {
             $output->writeln($message);
         }));
         Update::updateToCurrentVersion($configuration);
     } catch (Exception $x) {
         $output->writeln('<error>' . $x->getMessage() . '</error>');
         $rc = 1;
     }
     return $rc;
 }
Beispiel #2
0
 public function view()
 {
     $this->set('latest_version', \Concrete\Core\Updater\Update::getLatestAvailableVersionNumber());
     $tp = new \TaskPermission();
     $updates = 0;
     $local = array();
     $remote = array();
     if ($tp->canInstallPackages()) {
         $local = Package::getLocalUpgradeablePackages();
         $remote = Package::getRemotelyUpgradeablePackages();
     }
     // now we strip out any dupes for the total
     $updates = 0;
     $localHandles = array();
     foreach ($local as $_pkg) {
         $updates++;
         $localHandles[] = $_pkg->getPackageHandle();
     }
     foreach ($remote as $_pkg) {
         if (!in_array($_pkg->getPackageHandle(), $localHandles)) {
             $updates++;
         }
     }
     $this->set('updates', $updates);
 }
Beispiel #3
0
 public function submit()
 {
     if ($this->validateAction()) {
         try {
             Update::updateToCurrentVersion();
             $this->set('success', t('Upgrade to <b>%s</b> complete!', APP_VERSION));
         } catch (\Exception $e) {
             $this->set('error', $e);
         }
     }
 }
Beispiel #4
0
 public function download_update()
 {
     $p = new \Permissions();
     if (!$p->canUpgrade()) {
         return false;
     }
     $vt = Loader::helper('validation/token');
     if (!$vt->validate('download_update')) {
         $this->error->add($vt->getErrorMessage());
     }
     if (!is_dir(DIR_CORE_UPDATES)) {
         $this->error->add(t('The directory %s does not exist.', DIR_CORE_UPDATES));
     } else {
         if (!is_writable(DIR_CORE_UPDATES)) {
             $this->error->add(t('The directory %s must be writable by the web server.', DIR_CORE_UPDATES));
         }
     }
     if (!$this->error->has()) {
         $remote = \Concrete\Core\Updater\Update::getApplicationUpdateInformation();
         if (is_object($remote)) {
             // try to download
             $r = \Marketplace::downloadRemoteFile($remote->getDirectDownloadURL());
             if (empty($r) || $r == \Package::E_PACKAGE_DOWNLOAD) {
                 $response = array(\Package::E_PACKAGE_DOWNLOAD);
             } else {
                 if ($r == \Package::E_PACKAGE_SAVE) {
                     $response = array($r);
                 }
             }
             if (isset($response)) {
                 $errors = \Package::mapError($response);
                 foreach ($errors as $e) {
                     $this->error->add($e);
                 }
             }
             if (!$this->error->has()) {
                 // the file exists in the right spot
                 $ar = new UpdateArchive();
                 try {
                     $ar->install($r);
                 } catch (Exception $e) {
                     $this->error->add($e->getMessage());
                 }
             }
         } else {
             $this->error->add(t('Unable to retrieve software from update server.'));
         }
     }
     $this->view();
 }
 public function view()
 {
     $this->set('latest_version', Update::getLatestAvailableVersionNumber());
     $local = [];
     $remote = [];
     $p = new Permissions();
     if ($p->canInstallPackages()) {
         $local = Package::getLocalUpgradeablePackages();
         $remote = Package::getRemotelyUpgradeablePackages();
     }
     // now we strip out any dupes for the total
     $updates = 0;
     $localHandles = [];
     foreach ($local as $_pkg) {
         ++$updates;
         $localHandles[] = $_pkg->getPackageHandle();
     }
     foreach ($remote as $_pkg) {
         if (!in_array($_pkg->getPackageHandle(), $localHandles)) {
             ++$updates;
         }
     }
     $this->set('updates', $updates);
 }
Beispiel #6
0
 public function handleAutomaticUpdates()
 {
     $config = $this['config'];
     if ($config->get('concrete.updates.enable_auto_update_core')) {
         $installed = $config->get('concrete.version_installed');
         $core = $config->get('concrete.version');
         if ($core && $installed && version_compare($installed, $core, '<')) {
             Update::updateToCurrentVersion();
         }
     }
 }
 public function handleAutomaticUpdates()
 {
     $config = $this['config'];
     $installed = $config->get('concrete.version_db_installed');
     $core = $config->get('concrete.version_db');
     if ($installed < $core) {
         Update::updateToCurrentVersion();
     }
 }