Run database tasks and tests to see if Drupal can run on the database.

File

includes/install.inc, line 397
API functions for installing modules and themes.

Class

DatabaseTasks
Database installer structure.

Code

public function runTasks() {

  // We need to establish a connection before we can run tests.
  if ($this
    ->connect()) {
    foreach ($this->tasks as $task) {
      if (!isset($task['function'])) {
        $task['function'] = 'runTestQuery';
      }
      if (method_exists($this, $task['function'])) {

        // Returning false is fatal. No other tasks can run.
        if (FALSE === call_user_func_array(array(
          $this,
          $task['function'],
        ), $task['arguments'])) {
          break;
        }
      }
      else {
        throw new DatabaseTaskException(st("Failed to run all tasks against the database server. The task %task wasn't found.", array(
          '%task' => $task['function'],
        )));
      }
    }
  }

  // Check for failed results and compile message
  $message = '';
  foreach ($this->results as $result => $success) {
    if (!$success) {
      $message .= '<p class="error">' . $result . '</p>';
    }
  }
  if (!empty($message)) {
    $message = 'Resolve all issues below to continue the installation. For help configuring your database server, see the <a href="http://drupal.org/getting-started/install">installation handbook</a>, or contact your hosting provider.' . $message;
    throw new DatabaseTaskException($message);
  }
}