Logo Search packages:      
Sourcecode: aegir-provision version File versions  Download package

install_main (  ) 

Handles requirement checking

This code is based on install_check_requirements in install.php We separate this out because we want to avoid all the user interface code in this function, so we only use the relevant part of it.

Further installation tasks

This code is based on install_tasks() in install.php It has been modified to remove any calls to the user interface, and run all batches in the same process, instead of in a single page load.

Definition at line 115 of file install_6.inc.

References install_send_welcome_mail(), install_verify_drupal(), and install_verify_settings().

                        {
  require_once './includes/bootstrap.inc';
  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);

  // This must go after drupal_bootstrap(), which unsets globals!
  global $profile, $install_locale, $client_email, $conf, $url;

  require_once './modules/system/system.install';
  require_once './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 './includes/module.inc';
  $module_list['system']['filename'] = 'modules/system/system.module';
  $module_list['filter']['filename'] = 'modules/filter/filter.module';
  module_list(TRUE, FALSE, 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();
  // Drupal may already be installed.
  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 './includes/cache.inc';
    $conf['cache_inc'] = './includes/cache.inc';

    drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_DATABASE);

    if (install_verify_drupal()) {
      return drush_set_error('PROVISION_DRUPAL_SITE_INSTALLED');
    }
  }
  else {
    return drush_set_error('PROVISION_CONFIG_NOT_VALID');
  }


  drush_log(st("Installing Drupal schema"), 'install');
  // Load the profile.
  require_once "./profiles/$profile/$profile.profile";
  drush_log(st("Loading @profile install profile", array("@profile" => $profile)), 'install');

  drush_log(st("Installing translation : @locale", array("@locale" => $install_locale)), 'install');

  /**
   * Handles requirement checking
   *
   * This code is based on install_check_requirements in install.php
   * We separate this out because we want to avoid all the user interface
   * code in this function, so we only use the relevant part of it.
   */
  $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) {
        drupal_set_message($requirement['description'] .' ('. st('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) .')', 'error');
      }
    }
    $missing_requirement = TRUE;
  }
  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');
      }
    }
  }

  if ($missing_requirement) {
    return drush_set_error('PROVISION_INSTALL_MISSING_REQUIREMENTS');
  }

  // Verify existence of all required modules.
  $modules = drupal_verify_profile($profile, $language);

  if (!$modules) {
    return drush_set_error('PROVISION_DRUPAL_INSTALL_FAILED');
  }

  $system_path = dirname(drupal_get_filename('module', 'system', NULL));
  require_once './'. $system_path .'/system.install';
  module_invoke('system', 'install');
  $system_versions = drupal_get_schema_versions('system');
  $system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED;
  db_query("INSERT INTO {system} (filename, name, type, owner, status, throttle, bootstrap, schema_version) VALUES('%s', '%s', '%s', '%s', %d, %d, %d, %d)", $system_path .'/system.module', 'system', 'module', '', 1, 0, 0, $system_version);
  // Now that we've installed things properly, bootstrap the full Drupal environment

  module_rebuild_cache();
  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
  $modules = array_diff($modules, array('system'));

  if ($install_locale != 'en') {
    $modules = array_merge($modules, array('locale'));
  }
  /**
   * Further installation tasks
   *
   * This code is based on install_tasks() in install.php
   * It has been modified to remove any calls to the user interface,
   * and run all batches in the same process, instead of in a single page
   * load.
   */

  // profile-install and profile-install-batch tasks
  $files = module_rebuild_cache();
  foreach ($modules as $module) {
    _drupal_install_module($module);
    module_enable(array($module));
    drush_log(t("Installed @module module.", 
      array("@module" => $files[$module]->info['name'])));
  }

  module_invoke_all('init');

  drush_log("Initial locale import");
  // locale-initial-import and locale-inintial-batch tasks
  if (!empty($install_locale) && ($install_locale != 'en')) {
    include_once 'includes/locale.inc';
    // Enable installation language as default site language.
    locale_add_language($install_locale, NULL, NULL, NULL, NULL, NULL, 1, TRUE);
    // Collect files to import for this language.
    $batch = locale_batch_by_language($install_locale);
    if (!empty($batch)) {
      $install_locale_batch_components = $batch['#components'];
      batch_set($batch);
      $batch =& batch_get();
      $batch['progressive'] = FALSE;
      batch_process();
    }
  }

  // configure-task
  variable_set('site_name', $url);
  variable_set('site_mail', 'webmaster@' . $url);
  variable_set('clean_url', TRUE);
  variable_set('install_time', time());

  // Get the timezone offset from system time
  $tz_offset = date('Z');
  variable_set('date_default_timezone', $tz_offset);

  menu_rebuild();

  // profile task
  // @TODO support install profiles with multiple additional tasks
  $task = 'profile';

  $function = $profile .'_profile_tasks';

  if (function_exists($function)) {
    while (!in_array($task, array('profile-finished', 'finished'))) {
      drush_log(dt("Running profile specific task : !task", array('!task' => $task)));
      module_rebuild_cache();
      module_load_all();
      // stop batch api from re-directing. ever.
      $batch =& batch_get();
      $batch['progressive'] = FALSE;
      $batch['redirect'] = null;
      $batch['operations'] = array();
      $batch['url'] = 'batch';
      batch_set($batch);

      // The profile needs to run more code, maybe even more tasks.
      // $task is sent through as a reference and may be changed!
      $output = $function($task, $url);

      $task = variable_get('install_task', $task);
      variable_del('install_task');

      // If the profile doesn't move on to a new task we assume
      // that it is done.
      if ($task == 'profile') {
        $task = 'profile-finished';
      }
    }
  }

  if ($task == 'profile-finished') {
    // profile-finished task
    // Secondary locale import 
    if (!empty($install_locale) && ($install_locale != 'en')) {
      // Collect files to import for this language. Skip components
      // already covered in the initial batch set.
      $batch = locale_batch_by_language($install_locale, NULL, $install_locale_batch_components);
      if (!empty($batch)) {
        // Start a batch, switch to 'locale-remaining-batch' task. We need to
        // set the variable here, because batch_process() redirects.
        batch_set($batch);
        $batch =& batch_get();
        $batch['progressive'] = FALSE;
        batch_process();
      }
    }
  }

  // done task
  // Rebuild menu to get content type links registered by the profile,
  // and possibly any other menu items created through the tasks.
  menu_rebuild();

  // Register actions declared by any modules.
  actions_synchronize();

  // Randomize query-strings on css/js files, to hide the fact that
  // this is a new install, not upgraded yet.
  _drupal_flush_css_js();

  cache_clear_all();
  variable_set('install_profile', $profile);

  if ($client_email) {
    install_send_welcome_mail($url, $profile, $install_locale, $client_email);
  }
  variable_set('install_task', 'done');
}


Generated by  Doxygen 1.6.0   Back to index