Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         if (!$this->option('url')) {
             $output->write('Requesting Version...');
             $versions = $this->getVersions();
             $output->writeln('<info>done.</info>');
             $output->writeln('');
             $output->writeln('<comment>Latest Version: ' . $versions['latest']['version'] . '</comment> ');
             $output->writeln('');
             if (!$this->confirm('Update to Version ' . $versions['latest']['version'] . '? [y/n]')) {
                 return;
             }
             $output->writeln('');
             $url = $versions['latest']['url'];
         } else {
             $url = $this->option('url');
         }
         $tmpFile = tempnam($this->container['path.temp'], 'update_');
         $output->write('Downloading...');
         $this->download($url, $tmpFile);
         $output->writeln('<info>done.</info>');
         $updater = new SelfUpdater($output);
         $updater->update($tmpFile);
         $output->write('Migrating...');
         system(sprintf('php %s migrate', $_SERVER['PHP_SELF']));
     } catch (\Exception $e) {
         if (isset($tmpFile) && file_exists($tmpFile)) {
             unlink($tmpFile);
         }
         throw $e;
     }
 }
Exemplo n.º 2
0
 /**
  * @Request(csrf=true)
  */
 public function updateAction()
 {
     if (!($file = App::session()->get('system.update'))) {
         App::abort(400, __('You may not call this step directly.'));
     }
     App::session()->remove('system.update');
     return App::response()->stream(function () use($file) {
         try {
             if (!file_exists($file) || !is_file($file)) {
                 throw new \RuntimeException('File does not exist.');
             }
             $updater = new SelfUpdater();
             $updater->update($file);
         } catch (\Exception $e) {
             http_response_code(400);
             echo $e->getMessage();
         }
     });
 }
Exemplo n.º 3
0
 /**
  * @Request(csrf=true)
  */
 public function updateAction()
 {
     if (!($file = App::session()->get('system.update'))) {
         App::abort(400, __('You may not call this step directly.'));
     }
     App::session()->remove('system.update');
     return App::response()->stream(function () use($file) {
         $output = new StreamOutput(fopen('php://output', 'w'));
         try {
             if (!file_exists($file) || !is_file($file)) {
                 throw new \RuntimeException('File does not exist.');
             }
             $updater = new SelfUpdater($output);
             $updater->update($file);
         } catch (\Exception $e) {
             $output->writeln(sprintf("\n<error>%s</error>", $e->getMessage()));
             $output->write("status=error");
         }
     });
 }