예제 #1
0
 /**
  * @return array
  *
  * @see update_script_selection_form()
  */
 private function listUpdates()
 {
     // [
     //   'oxygen' => [
     //   'pending' => [
     //     7001 => 'Update description.',
     //   ],
     //   'start' => 7001,
     // ],
     $list = array();
     require_once DRUPAL_ROOT . '/includes/install.inc';
     drupal_load_updates();
     foreach (update_get_update_list() as $extension => $info) {
         if (!isset($info['start'])) {
             // @todo: The update is incompatible, show a warning?
             continue;
         }
         $list[$extension] = $info['start'];
     }
     $updates = array();
     foreach (update_resolve_dependencies($list) as $update) {
         if (!$update['allowed']) {
             if ($update['missing_dependencies']) {
                 // Some module dependency is missing, so it's not safe to update.
                 continue;
             } else {
                 // There was a PHP syntax error in the module.
                 continue;
             }
         }
         $updates = array($update['module'] => $update['number']) + $updates;
     }
     return $updates;
 }
예제 #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $this->getDrupalHelper()->loadLegacyFile('/core/includes/install.inc');
     $this->getDrupalHelper()->loadLegacyFile('/core/includes/update.inc');
     $module = $input->getArgument('module');
     $update_n = $input->getArgument('update-n');
     $module_handler = $this->getModuleHandler();
     drupal_load_updates();
     update_fix_compatibility();
     $updates = update_get_update_list();
     if ($module != 'all') {
         if (!isset($updates[$module])) {
             $io->error(sprintf($this->trans('commands.update.execute.messages.no-module-updates'), $module));
             return;
         } else {
             // filter to execute only a specific module updates
             $updates = [$module => $updates[$module]];
             if ($update_n && !isset($updates[$module]['pending'][$update_n])) {
                 $io->info(sprintf($this->trans('commands.update.execute.messages.module-update-function-not-found'), $module, $update_n));
             }
         }
     }
     $io->info($this->trans('commands.site.maintenance.description'));
     $state = $this->getService('state');
     $state->set('system.maintenance_mode', true);
     foreach ($updates as $module_name => $module_updates) {
         foreach ($module_updates['pending'] as $update_number => $update) {
             if ($module != 'all' && $update_n !== null && $update_n != $update_number) {
                 continue;
             }
             //Executing all pending updates
             if ($update_n > $module_updates['start']) {
                 $io->info($this->trans('commands.update.execute.messages.executing-required-previous-updates'));
             }
             for ($update_index = $module_updates['start']; $update_index <= $update_number; $update_index++) {
                 $io->info(sprintf($this->trans('commands.update.execute.messages.executing-update'), $update_index, $module_name));
                 try {
                     $module_handler->invoke($module_name, 'update_' . $update_index);
                 } catch (\Exception $e) {
                     watchdog_exception('update', $e);
                     $io->error($e->getMessage());
                 }
                 //Update module schema version
                 drupal_set_installed_schema_version($module_name, $update_index);
             }
         }
     }
     $state->set('system.maintenance_mode', false);
     $io->info($this->trans('commands.site.maintenance.messages.maintenance-off'));
     $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
 }
예제 #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /*      drupal_set_installed_schema_version('sample', '8000');
             exit();*/
     include_once DRUPAL_ROOT . '/core/includes/install.inc';
     include_once DRUPAL_ROOT . '/core/includes/update.inc';
     $module = $input->getArgument('module');
     $update_n = $input->getArgument('update-n');
     $module_handler = $this->getModuleHandler();
     drupal_load_updates();
     update_fix_compatibility();
     $updates = update_get_update_list();
     if ($module != 'all') {
         if (!isset($updates[$module])) {
             $output->writeln('[-] <error>' . sprintf($this->trans('commands.update.execute.messages.no-module-updates'), $module) . '</error>');
             return;
         } else {
             // filter to execute only a specific module updates
             $updates = [$module => $updates[$module]];
             if ($update_n && !isset($updates[$module]['pending'][$update_n])) {
                 $output->writeln('[-] <info>' . sprintf($this->trans('commands.update.execute.messages.module-update-function-not-found'), $module, $update_n) . '</info>');
             }
         }
     }
     $output->writeln('[-] <info>' . $this->trans('commands.site.maintenance.description') . '</info>');
     \Drupal::state()->set('system.maintenance_mode', true);
     foreach ($updates as $module_name => $module_updates) {
         foreach ($module_updates['pending'] as $update_number => $update) {
             if ($module != 'all' && $update_n != null and $update_n != $update_number) {
                 continue;
             }
             //Executing all pending updates
             if ($update_n > $module_updates['start']) {
                 $output->writeln('[-] <info>' . $this->trans('commands.update.execute.messages.executing-required-previous-updates') . '</info>');
             }
             for ($update_index = $module_updates['start']; $update_index <= $update_number; $update_index++) {
                 $output->writeln('[-] <info>' . sprintf($this->trans('commands.update.execute.messages.executing-update'), $update_index, $module_name) . '</info>');
                 try {
                     $module_handler->invoke($module_name, 'update_' . $update_index);
                 } catch (\Exception $e) {
                     watchdog_exception('update', $e);
                     $output->writeln('<error>' . $e->getMessage() . '</error>');
                 }
                 //Update module schema version
                 drupal_set_installed_schema_version($module_name, $update_index);
             }
         }
     }
     \Drupal::state()->set('system.maintenance_mode', false);
     $output->writeln('[-] <info>' . $this->trans('commands.site.maintenance.messages.maintenance-off') . '</info>');
     $this->getHelper('chain')->addCommand('cache:rebuild', ['cache' => 'all']);
 }
예제 #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $this->get('site')->loadLegacyFile('/core/includes/update.inc');
     $this->get('site')->loadLegacyFile('/core/includes/install.inc');
     $updateRegistry = $this->getDrupalService('update.post_update_registry');
     drupal_load_updates();
     update_fix_compatibility();
     $updates = update_get_update_list();
     $postUpdates = $updateRegistry->getPendingUpdateInformation();
     $requirements = update_check_requirements();
     $severity = drupal_requirements_severity($requirements);
     $io->newLine();
     if ($severity == REQUIREMENT_ERROR || $severity == REQUIREMENT_WARNING) {
         $io->info($this->trans('commands.update.debug.messages.requirements-error'));
         $tableHeader = [$this->trans('commands.update.debug.messages.severity'), $this->trans('commands.update.debug.messages.title'), $this->trans('commands.update.debug.messages.value'), $this->trans('commands.update.debug.messages.description')];
         $tableRows = [];
         foreach ($requirements as $requirement) {
             if (isset($requirement['minimum schema']) & in_array($requirement['minimum schema'], array(REQUIREMENT_ERROR, REQUIREMENT_WARNING))) {
                 $tableRows[] = [$requirement['severity'], $requirement['title'], $requirement['value'], $requirement['description']];
             }
         }
         $io->table($tableHeader, $tableRows);
         return;
     }
     if (empty($updates)) {
         $io->info($this->trans('commands.update.debug.messages.no-updates'));
         return;
     }
     $tableHeader = [$this->trans('commands.update.debug.messages.module'), $this->trans('commands.update.debug.messages.update-n'), $this->trans('commands.update.debug.messages.description')];
     $io->info($this->trans('commands.update.debug.messages.module-list'));
     $tableRows = [];
     foreach ($updates as $module => $module_updates) {
         foreach ($module_updates['pending'] as $update_n => $update) {
             list(, $description) = explode($update_n . " - ", $update);
             $tableRows[] = [$module, $update_n, trim($description)];
         }
     }
     $io->table($tableHeader, $tableRows);
     $tableHeader = [$this->trans('commands.update.debug.messages.module'), $this->trans('commands.update.debug.messages.post-update'), $this->trans('commands.update.debug.messages.description')];
     $io->info($this->trans('commands.update.debug.messages.module-list-post-update'));
     $tableRows = [];
     foreach ($postUpdates as $module => $module_updates) {
         foreach ($module_updates['pending'] as $postUpdateFunction => $message) {
             $tableRows[] = [$module, $postUpdateFunction, $message];
         }
     }
     $io->table($tableHeader, $tableRows);
 }
예제 #5
0
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $this->module = $input->getArgument('module');
     $this->update_n = $input->getArgument('update-n');
     $this->site->loadLegacyFile('/core/includes/install.inc');
     $this->site->loadLegacyFile('/core/includes/update.inc');
     drupal_load_updates();
     update_fix_compatibility();
     $updates = update_get_update_list();
     $this->checkUpdates($io);
     $io->info($this->trans('commands.site.maintenance.description'));
     $this->state->set('system.maintenance_mode', true);
     $this->runUpdates($io, $updates);
     $this->runPostUpdates($io);
     $this->state->set('system.maintenance_mode', false);
     $io->info($this->trans('commands.site.maintenance.messages.maintenance-off'));
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
 }
예제 #6
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $this->get('site')->loadLegacyFile('/core/includes/update.inc');
     $this->get('site')->loadLegacyFile('/core/includes/install.inc');
     drupal_load_updates();
     update_fix_compatibility();
     $requirements = update_check_requirements();
     $severity = drupal_requirements_severity($requirements);
     $updates = update_get_update_list();
     $io->newLine();
     if ($severity == REQUIREMENT_ERROR || $severity == REQUIREMENT_WARNING) {
         $this->populateRequirements($io, $requirements);
     } elseif (empty($updates)) {
         $io->info($this->trans('commands.update.debug.messages.no-updates'));
     } else {
         $this->populateUpdate($io, $updates);
         $this->populatePostUpdate($io);
     }
 }
예제 #7
0
 /**
  * Collects data for the given Request and Response.
  *
  * @param Request    $request   A Request instance
  * @param Response   $response  A Response instance
  * @param \Exception $exception An Exception instance
  *
  * @api
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     if ($this->matcher->matches($request)) {
         $this->data = array('bootstrap' => function_exists('drupal_get_bootstrap_phase') ? drupal_get_bootstrap_phase() : -1, 'base_url' => $GLOBALS['base_url'], 'base_path' => $GLOBALS['base_path'], 'base_root' => $GLOBALS['base_root'], 'conf_path' => conf_path(), 'queries' => array());
         // Load .install files
         include_once DRUPAL_ROOT . '/includes/install.inc';
         drupal_load_updates();
         // Check run-time requirements and status information.
         $requirements = module_invoke_all('requirements', 'runtime');
         usort($requirements, '_system_sort_requirements');
         $this->data['requirements'] = $requirements;
         $this->data['severity'] = drupal_requirements_severity($requirements);
         $this->data['status_report'] = theme('status_report', array('requirements' => $requirements));
         if (isset($GLOBALS['databases']) && is_array($GLOBALS['databases'])) {
             foreach (array_keys($GLOBALS['databases']) as $key) {
                 $this->data['queries'][$key] = \Database::getLog('devel', $key);
             }
         }
     } else {
         $this->data = false;
     }
 }
예제 #8
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $table = $this->getHelperSet()->get('table');
     $table->setlayout($table::LAYOUT_COMPACT);
     include_once DRUPAL_ROOT . '/core/includes/update.inc';
     include_once DRUPAL_ROOT . '/core/includes/install.inc';
     $module_handler = $this->getModuleHandler();
     drupal_load_updates();
     update_fix_compatibility();
     $updates = update_get_update_list();
     $requirements = update_check_requirements();
     $severity = drupal_requirements_severity($requirements);
     if ($severity == REQUIREMENT_ERROR || $severity == REQUIREMENT_WARNING) {
         $output->writeln('[-] <info>' . $this->trans('commands.update.debug.messages.requirements-error') . '</info>');
         $table->setHeaders([$this->trans('commands.update.debug.messages.severity'), $this->trans('commands.update.debug.messages.title'), $this->trans('commands.update.debug.messages.value'), $this->trans('commands.update.debug.messages.description')]);
         foreach ($requirements as $requirement) {
             if (isset($requirement['minimum schema']) & in_array($requirement['minimum schema'], array(REQUIREMENT_ERROR, REQUIREMENT_WARNING))) {
                 $table->addRow([$requirement['severity'], $requirement['title'], $requirement['value'], $requirement['description']]);
             }
         }
         $table->render($output);
         return;
     }
     if (empty($updates)) {
         $output->writeln('[-] <info>' . $this->trans('commands.update.debug.messages.no-updates') . '</info>');
         return;
     }
     $table->setHeaders([$this->trans('commands.update.debug.messages.module'), $this->trans('commands.update.debug.messages.update-n'), $this->trans('commands.update.debug.messages.description')]);
     $output->writeln('<info>' . $this->trans('commands.update.debug.messages.module-list') . '</info>');
     foreach ($updates as $module => $module_updates) {
         foreach ($module_updates['pending'] as $update_n => $update) {
             list(, $description) = split($update_n . " - ", $update);
             $table->addRow([$module, $update_n, trim($description)]);
         }
     }
     $table->render($output);
 }
예제 #9
0
 /**
  * Returns a database update page.
  *
  * @param string $op
  *   The update operation to perform. Can be any of the below:
  *    - info
  *    - selection
  *    - run
  *    - results
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request object.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  *   A response object object.
  */
 public function handle($op, Request $request)
 {
     require_once $this->root . '/core/includes/install.inc';
     require_once $this->root . '/core/includes/update.inc';
     drupal_load_updates();
     update_fix_compatibility();
     if ($request->query->get('continue')) {
         $_SESSION['update_ignore_warnings'] = TRUE;
     }
     $regions = array();
     $requirements = update_check_requirements();
     $severity = drupal_requirements_severity($requirements);
     if ($severity == REQUIREMENT_ERROR || $severity == REQUIREMENT_WARNING && empty($_SESSION['update_ignore_warnings'])) {
         $regions['sidebar_first'] = $this->updateTasksList('requirements');
         $output = $this->requirements($severity, $requirements, $request);
     } else {
         switch ($op) {
             case 'selection':
                 $regions['sidebar_first'] = $this->updateTasksList('selection');
                 $output = $this->selection($request);
                 break;
             case 'run':
                 $regions['sidebar_first'] = $this->updateTasksList('run');
                 $output = $this->triggerBatch($request);
                 break;
             case 'info':
                 $regions['sidebar_first'] = $this->updateTasksList('info');
                 $output = $this->info($request);
                 break;
             case 'results':
                 $regions['sidebar_first'] = $this->updateTasksList('results');
                 $output = $this->results($request);
                 break;
                 // Regular batch ops : defer to batch processing API.
             // Regular batch ops : defer to batch processing API.
             default:
                 require_once $this->root . '/core/includes/batch.inc';
                 $regions['sidebar_first'] = $this->updateTasksList('run');
                 $output = _batch_page($request);
                 break;
         }
     }
     if ($output instanceof Response) {
         return $output;
     }
     $title = isset($output['#title']) ? $output['#title'] : $this->t('Drupal database update');
     return $this->bareHtmlPageRenderer->renderBarePage($output, $title, 'maintenance_page', $regions);
 }
예제 #10
0
 /**
  * Displays the site status report. Can also be used as a pure check.
  *
  * @return array
  *   An array of system requirements.
  */
 public function listRequirements()
 {
     // Load .install files
     include_once DRUPAL_ROOT . '/core/includes/install.inc';
     drupal_load_updates();
     // Check run-time requirements and status information.
     $requirements = $this->moduleHandler->invokeAll('requirements', array('runtime'));
     usort($requirements, function ($a, $b) {
         if (!isset($a['weight'])) {
             if (!isset($b['weight'])) {
                 return strcmp($a['title'], $b['title']);
             }
             return -$b['weight'];
         }
         return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
     });
     return $requirements;
 }
예제 #11
0
    drupal_maintenance_theme();
    // Check the update requirements for Drupal.
    update_check_requirements();
    // Redirect to the update information page if all requirements were met.
    install_goto('update.php?op=info');
}
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_maintenance_theme();
// Turn error reporting back on. From now on, only fatal errors (which are
// not passed through the error handler) will cause a message to be printed.
ini_set('display_errors', TRUE);
// Only proceed with updates if the user is allowed to run them.
if ($update_access_allowed) {
    include_once DRUPAL_ROOT . '/includes/install.inc';
    include_once DRUPAL_ROOT . '/includes/batch.inc';
    drupal_load_updates();
    update_fix_d7_requirements();
    update_fix_compatibility();
    $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
    switch ($op) {
        // update.php ops
        case 'selection':
            if (isset($_GET['token']) && $_GET['token'] == drupal_get_token('update')) {
                $output = update_selection_page();
                break;
            }
        case 'Apply pending updates':
            if (isset($_GET['token']) && $_GET['token'] == drupal_get_token('update')) {
                update_batch();
                break;
            }
예제 #12
0
  /**
   * Implements \SiteAudit\Check\Abstract\calculateScore().
   */
  public function calculateScore() {
    // See system/system.admin.inc function system_status().
    // Load .install files.
    include_once DRUPAL_ROOT . '/includes/install.inc';
    drupal_load_updates();

    // Check run-time requirements and status information.
    $this->registry['requirements'] = module_invoke_all('requirements', 'runtime');
    usort($this->registry['requirements'], '_system_sort_requirements');

    $this->percentOverride = 0;
    $score_each = 100 / count($this->registry['requirements']);

    $worst_severity = REQUIREMENT_INFO;
    foreach ($this->registry['requirements'] as $requirement) {
      if ($requirement['severity'] > $worst_severity) {
        $worst_severity = $requirement['severity'];
      }
      if ($requirement['severity'] == REQUIREMENT_WARNING) {
        $this->percentOverride += $score_each / 2;
      }
      elseif ($requirement['severity'] != REQUIREMENT_ERROR) {
        $this->percentOverride += $score_each;
      }
    }

    $this->percentOverride = round($this->percentOverride);

    if ($this->percentOverride > 80) {
      return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
    }
    elseif ($this->percentOverride > 60) {
      return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
    }
    return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
  }