function install_database_errors in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/includes/install.core.inc \install_database_errors()
Checks a database connection and returns any errors.
2 calls to install_database_errors()
- install_verify_database_settings in core/
includes/ install.core.inc - Verifies that settings.php specifies a valid database connection.
- SiteSettingsForm::validateForm in core/
lib/ Drupal/ Core/ Installer/ Form/ SiteSettingsForm.php - Form validation handler.
File
- core/
includes/ install.core.inc, line 1115 - API functions for installing Drupal.
Code
function install_database_errors($database, $settings_file) {
$errors = array();
// Check database type.
$database_types = drupal_get_database_types();
$driver = $database['driver'];
if (!isset($database_types[$driver])) {
$errors['driver'] = t("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", array(
'%settings_file' => $settings_file,
'@drupal' => drupal_install_profile_distribution_name(),
'%driver' => $driver,
));
}
else {
// Run driver specific validation
$errors += $database_types[$driver]
->validateDatabaseSettings($database);
if (!empty($errors)) {
// No point to try further.
return $errors;
}
// Run tasks associated with the database type. Any errors are caught in the
// calling function.
Database::addConnectionInfo('default', 'default', $database);
$errors = db_installer_object($driver)
->runTasks();
if (count($errors)) {
$error_message = [
'#type' => 'inline_template',
'#template' => '{% trans %}Resolve all issues below to continue the installation. For help configuring your database server, see the <a href="https://www.drupal.org/getting-started/install">installation handbook</a>, or contact your hosting provider.{% endtrans%}{{ errors }}',
'#context' => [
'errors' => [
'#theme' => 'item_list',
'#items' => $errors,
],
],
];
// These are generic errors, so we do not have any specific key of the
// database connection array to attach them to; therefore, we just put
// them in the error array with standard numeric keys.
$errors[$driver . '][0'] = \Drupal::service('renderer')
->renderPlain($error_message);
}
}
return $errors;
}