Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
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;
     }
 }
Ejemplo n.º 4
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);
 }
Ejemplo n.º 5
0
/**
 * Check installation requirements and report any errors.
 */
function install_check_requirements($profile, $verify)
{
    // If Drupal is not set up already, we need to create a settings file.
    if (!$verify) {
        $writable = FALSE;
        $conf_path = './' . conf_path(FALSE, TRUE);
        $settings_file = $conf_path . '/settings.php';
        $file = $conf_path;
        $exists = FALSE;
        // Verify that the directory exists.
        if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) {
            // Check to make sure a settings.php already exists.
            $file = $settings_file;
            if (drupal_verify_install_file($settings_file, FILE_EXIST)) {
                $exists = TRUE;
                // If it does, make sure it is writable.
                $writable = drupal_verify_install_file($settings_file, FILE_READABLE | FILE_WRITABLE);
            }
        }
        if (!$exists) {
            drupal_set_message(st('The @drupal installer requires that you create a settings file as part of the installation process.
<ol>
<li>Copy the %default_file file to %file.</li>
<li>Change file permissions so that it is writable by the web server. If you are unsure how to grant file permissions, please consult the <a href="@handbook_url">on-line handbook</a>.</li>
</ol>
More details about installing Drupal are available in INSTALL.txt.', array('@drupal' => drupal_install_profile_name(), '%file' => $file, '%default_file' => $conf_path . '/default.settings.php', '@handbook_url' => 'http://drupal.org/server-permissions')), 'error');
        } elseif (!$writable) {
            drupal_set_message(st('The @drupal installer requires write permissions to %file during the installation process. If you are unsure how to grant file permissions, please consult the <a href="@handbook_url">on-line handbook</a>.', array('@drupal' => drupal_install_profile_name(), '%file' => $file, '@handbook_url' => 'http://drupal.org/server-permissions')), 'error');
        }
    }
    // Check the other requirements.
    $requirements = drupal_check_profile($profile);
    $severity = drupal_requirements_severity($requirements);
    // If there are issues, report them.
    if ($severity == REQUIREMENT_ERROR) {
        foreach ($requirements as $requirement) {
            if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
                $message = $requirement['description'];
                if (isset($requirement['value']) && $requirement['value']) {
                    $message .= ' (' . st('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) . ')';
                }
                drupal_set_message($message, 'error');
            }
        }
    }
    if ($severity == REQUIREMENT_WARNING) {
        foreach ($requirements as $requirement) {
            if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_WARNING) {
                $message = $requirement['description'];
                if (isset($requirement['value']) && $requirement['value']) {
                    $message .= ' (' . st('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) . ')';
                }
                drupal_set_message($message, 'warning');
            }
        }
    }
}
Ejemplo n.º 6
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);
 }
Ejemplo n.º 7
0
/**
 * Check update requirements and report any errors.
 */
function update_check_requirements()
{
    // Check the system module and update.php requirements only.
    $requirements = module_invoke('system', 'requirements', 'update');
    $requirements += update_extra_requirements();
    $severity = drupal_requirements_severity($requirements);
    // If there are issues, report them.
    if ($severity == REQUIREMENT_ERROR) {
        update_task_list('requirements');
        drupal_set_title('Requirements problem');
        $status_report = theme('status_report', $requirements);
        $status_report .= 'Please check the error messages and <a href="' . request_uri() . '">try again</a>.';
        print theme('update_page', $status_report);
        exit;
    }
}
Ejemplo n.º 8
0
/**
 * Check update requirements and report any errors.
 */
function update_check_requirements()
{
    // Check requirements of all loaded modules.
    $requirements = module_invoke_all('requirements', 'update');
    $requirements += update_extra_requirements();
    $severity = drupal_requirements_severity($requirements);
    // If there are issues, report them.
    if ($severity == REQUIREMENT_ERROR) {
        update_task_list('requirements');
        drupal_set_title('Requirements problem');
        $status_report = theme('status_report', array('requirements' => $requirements));
        $status_report .= 'Check the error messages and <a href="' . check_url(request_uri()) . '">try again</a>.';
        print theme('update_page', array('content' => $status_report));
        exit;
    }
}
Ejemplo n.º 9
0
Archivo: update.php Proyecto: c4rl/6
/**
 * Check update requirements and report any errors.
 */
function update_check_requirements()
{
    // Check the system module requirements only.
    $requirements = module_invoke('system', 'requirements', 'update');
    $severity = drupal_requirements_severity($requirements);
    // If there are issues, report them.
    if ($severity != REQUIREMENT_OK) {
        foreach ($requirements as $requirement) {
            if (isset($requirement['severity']) && $requirement['severity'] != REQUIREMENT_OK) {
                $message = isset($requirement['description']) ? $requirement['description'] : '';
                if (isset($requirement['value']) && $requirement['value']) {
                    $message .= ' (Currently using ' . $requirement['title'] . ' ' . $requirement['value'] . ')';
                }
                drupal_set_message($message, 'warning');
            }
        }
    }
}
Ejemplo n.º 10
0
/**
 * Page to check installation requirements and report any errors.
 */
function install_check_requirements($profile)
{
    $requirements = drupal_check_profile($profile);
    $severity = drupal_requirements_severity($requirements);
    // If there are issues, report them.
    if ($severity == REQUIREMENT_ERROR) {
        drupal_maintenance_theme();
        foreach ($requirements as $requirement) {
            if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
                drupal_set_message($requirement['description'] . ' (' . st('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) . ')', 'error');
            }
        }
        drupal_set_title(st('Incompatible environment'));
        print theme('install_page', '');
        exit;
    }
}
Ejemplo n.º 11
0
/**
 * The Drupal installation happens in a series of steps. We begin by verifying
 * that the current environment meets our minimum requirements. We then go
 * on to verify that settings.php is properly configured. From there we
 * connect to the configured database and verify that it meets our minimum
 * requirements. Finally we can allow the user to select an installation
 * profile and complete the installation process.
 *
 * @param $phase
 *   The installation phase we should proceed to.
 */
function install_main()
{
    // The user agent header is used to pass a database prefix in the request when
    // running tests. However, for security reasons, it is imperative that no
    // installation be permitted using such a prefix.
    if (preg_match("/^simpletest\\d+\$/", $_SERVER['HTTP_USER_AGENT'])) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
        exit;
    }
    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
    // This must go after drupal_bootstrap(), which unsets globals!
    global $profile, $install_locale, $conf;
    require_once DRUPAL_ROOT . '/modules/system/system.install';
    require_once DRUPAL_ROOT . '/includes/file.inc';
    // Ensure correct page headers are sent (e.g. caching)
    drupal_page_header();
    // Set up $language, so t() caller functions will still work.
    drupal_init_language();
    // Load module basics (needed for hook invokes).
    include_once DRUPAL_ROOT . '/includes/module.inc';
    include_once DRUPAL_ROOT . '/includes/session.inc';
    $module_list['system']['filename'] = 'modules/system/system.module';
    $module_list['filter']['filename'] = 'modules/filter/filter.module';
    module_list(TRUE, FALSE, $module_list);
    drupal_load('module', 'system');
    drupal_load('module', 'filter');
    // Set up theme system for the maintenance page.
    drupal_maintenance_theme();
    // Check existing settings.php.
    $verify = install_verify_settings();
    if ($verify) {
        // Since we have a database connection, we use the normal cache system.
        // This is important, as the installer calls into the Drupal system for
        // the clean URL checks, so we should maintain the cache properly.
        require_once DRUPAL_ROOT . '/includes/cache.inc';
        $conf['cache_inc'] = 'includes/cache.inc';
        // Initialize the database system. Note that the connection
        // won't be initialized until it is actually requested.
        require_once DRUPAL_ROOT . '/includes/database/database.inc';
        // Check if Drupal is installed.
        $task = install_verify_drupal();
        if ($task == 'done') {
            install_already_done_error();
        }
    } else {
        // Since no persistent storage is available yet, and functions that check
        // for cached data will fail, we temporarily replace the normal cache
        // system with a stubbed-out version that short-circuits the actual
        // caching process and avoids any errors.
        require_once DRUPAL_ROOT . '/includes/cache-install.inc';
        $conf['cache_inc'] = 'includes/cache-install.inc';
        $task = NULL;
    }
    // Decide which profile to use.
    if (!empty($_GET['profile'])) {
        $profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']);
    } elseif ($profile = install_select_profile()) {
        install_goto("install.php?profile={$profile}");
    } else {
        install_no_profile_error();
    }
    // Load the profile.
    require_once DRUPAL_ROOT . "/profiles/{$profile}/{$profile}.profile";
    // Locale selection
    if (!empty($_GET['locale'])) {
        $install_locale = preg_replace('/[^a-zA-Z_0-9\\-]/', '', $_GET['locale']);
    } elseif (($install_locale = install_select_locale($profile)) !== FALSE) {
        install_goto("install.php?profile={$profile}&locale={$install_locale}");
    }
    // Tasks come after the database is set up
    if (!$task) {
        global $db_url;
        if (!$verify && !empty($db_url)) {
            // Do not install over a configured settings.php.
            install_already_done_error();
        }
        // Check the installation requirements for Drupal and this profile.
        $requirements = install_check_requirements($profile, $verify);
        // Verify existence of all required modules.
        $requirements += drupal_verify_profile($profile, $install_locale);
        // Check the severity of the requirements reported.
        $severity = drupal_requirements_severity($requirements);
        if ($severity == REQUIREMENT_ERROR) {
            install_task_list('requirements');
            drupal_set_title(st('Requirements problem'));
            $status_report = theme('status_report', $requirements);
            $status_report .= st('Please check the error messages and <a href="!url">try again</a>.', array('!url' => request_uri()));
            print theme('install_page', $status_report);
            exit;
        }
        // Change the settings.php information if verification failed earlier.
        // Note: will trigger a redirect if database credentials change.
        if (!$verify) {
            install_change_settings($profile, $install_locale);
        }
        // Install system.module.
        drupal_install_system();
        // Save the list of other modules to install for the 'profile-install'
        // task. variable_set() can be used now that system.module is installed
        // and drupal is bootstrapped.
        $modules = drupal_get_profile_modules($profile, $install_locale);
        variable_set('install_profile_modules', array_diff($modules, array('system')));
    }
    // The database is set up, turn to further tasks.
    install_tasks($profile, $task);
}
Ejemplo n.º 12
0
/**
 * Installation task; verify the requirements for installing Drupal.
 *
 * @param $install_state
 *   An array of information about the current installation state.
 * @return
 *   A themed status report, or an exception if there are requirement errors.
 *   Otherwise, no output is returned, so that the next task can be run
 *   in the same page request.
 */
function install_verify_requirements(&$install_state)
{
    // Check the installation requirements for Drupal and this profile.
    $requirements = install_check_requirements($install_state);
    // Verify existence of all required modules.
    $requirements += drupal_verify_profile($install_state);
    // Check the severity of the requirements reported.
    $severity = drupal_requirements_severity($requirements);
    if ($severity == REQUIREMENT_ERROR) {
        if ($install_state['interactive']) {
            drupal_set_title(st('Requirements problem'));
            $status_report = theme('status_report', array('requirements' => $requirements));
            $status_report .= st('Check the error messages and <a href="!url">proceed with the installation</a>.', array('!url' => request_uri()));
            return $status_report;
        } else {
            // Throw an exception showing all unmet requirements.
            $failures = array();
            foreach ($requirements as $requirement) {
                if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
                    $failures[] = $requirement['title'] . ': ' . $requirement['value'] . "\n\n" . $requirement['description'];
                }
            }
            throw new Exception(implode("\n\n", $failures));
        }
    }
}
Ejemplo n.º 13
0
/**
 * Checks update requirements and reports errors and (optionally) warnings.
 *
 * @param $skip_warnings
 *   (optional) If set to TRUE, requirement warnings will be ignored, and a
 *   report will only be issued if there are requirement errors. Defaults to
 *   FALSE.
 */
function update_check_requirements($skip_warnings = FALSE)
{
    // Check requirements of all loaded modules.
    $requirements = module_invoke_all('requirements', 'update');
    $requirements += update_extra_requirements();
    $severity = drupal_requirements_severity($requirements);
    // If there are errors, always display them. If there are only warnings, skip
    // them if the caller has indicated they should be skipped.
    if ($severity == REQUIREMENT_ERROR || $severity == REQUIREMENT_WARNING && !$skip_warnings) {
        update_task_list('requirements');
        drupal_set_title('Requirements problem');
        $status_report = theme('status_report', array('requirements' => $requirements));
        $status_report .= 'Check the error messages and <a href="' . check_url(drupal_requirements_url($severity)) . '">try again</a>.';
        print theme('update_page', array('content' => $status_report));
        exit;
    }
}
Ejemplo n.º 14
0
/**
 * Check update requirements and report any errors.
 */
function update_check_requirements()
{
    global $db_url, $databases;
    $requirements = array();
    // If we will rewrite the settings.php then we need to make sure it is
    // writeable.
    if (empty($databases) && !empty($db_url) && is_string($db_url)) {
        $requirements = install_check_requirements('', FALSE);
    }
    $warnings = FALSE;
    // Check the system module requirements only.
    $requirements += module_invoke('system', 'requirements', 'update');
    $severity = drupal_requirements_severity($requirements);
    // If there are issues, report them.
    if ($severity != REQUIREMENT_OK) {
        foreach ($requirements as $requirement) {
            if (isset($requirement['severity']) && $requirement['severity'] != REQUIREMENT_OK) {
                $message = isset($requirement['description']) ? $requirement['description'] : '';
                if (isset($requirement['value']) && $requirement['value']) {
                    $message .= ' (Currently using ' . $requirement['title'] . ' ' . $requirement['value'] . ')';
                }
                $warnings = TRUE;
                drupal_set_message($message, 'warning');
            }
        }
    }
    return $warnings;
}