1 install.core.inc install_check_requirements($install_state)

Checks installation requirements and reports any errors.

File

core/includes/install.core.inc, line 1756
API functions for installing Backdrop.

Code

function install_check_requirements($install_state) {
  $profile = $install_state['parameters']['profile'];

  $requirements = array();

  // If Backdrop is not set up already, we need to update the settings file.
  if (!$install_state['settings_verified']) {
    $writable = FALSE;
    $conf_path = conf_path(FALSE, TRUE);
    $settings_file = $conf_path . '/settings.php';
    $exists = FALSE;
    // Verify that the directory exists.
    if (backdrop_verify_install_file($conf_path, FILE_EXIST, 'dir')) {
      // Check if a settings.php file already exists.
      if (backdrop_verify_install_file($settings_file, FILE_EXIST)) {
        // If it does, make sure it is writable.
        $writable = backdrop_verify_install_file($settings_file, FILE_READABLE | FILE_WRITABLE);
        $exists = TRUE;
      }
      elseif ($settings_file !== './settings.php') {
        if (copy('./settings.php', $settings_file) === TRUE) {
          $exists = TRUE;
          $writable = backdrop_verify_install_file($settings_file, FILE_READABLE | FILE_WRITABLE);
        }
      }
    }

    // If settings.php does not exist, throw an error.
    if (!$exists) {
      $requirements['settings file exists'] = array(
        'title' => st('Settings file'),
        'value' => st('The settings file does not exist.'),
        'severity' => REQUIREMENT_ERROR,
        'description' => st('The @profile installer could not find a settings.php file. Please place copy of this file into @file.', array('@profile' => backdrop_install_profile_distribution_name(), '@file' => $settings_file)),
      );
      return $requirements;
    }
    else {
      $requirements['settings file exists'] = array(
        'title' => st('Settings file'),
        'value' => st('The %file file exists.', array('%file' => $settings_file)),
      );
    }
    // If settings.php is not writable, throw an error.
    if (!$writable) {
      $requirements['settings file writable'] = array(
        'title' => st('Settings file'),
        'value' => st('The settings file is not writable.'),
        'severity' => REQUIREMENT_ERROR,
        'description' => st('The @profile installer requires write permissions to %file during the installation process. If you are unsure how to grant file permissions, consult the <a href="@handbook_url">Installation Instructions</a> page.', array('@profile' => backdrop_install_profile_distribution_name(), '%file' => $settings_file, '@handbook_url' => 'https://backdropcms.org/installation')),
      );
    }
    else {
      $requirements['settings file'] = array(
        'title' => st('Settings file'),
        'value' => st('The settings file is writable.'),
      );
    }
  }

  // Check the profile requirements.
  $requirements += backdrop_check_profile($profile);

  return $requirements;
}