1 install.core.inc | install_database_errors($database, $settings_file) |
Checks a database connection and returns any errors.
File
- core/
includes/ install.core.inc, line 1030 - API functions for installing Backdrop.
Code
function install_database_errors($database, $settings_file) {
global $databases;
$errors = array();
// Check database type.
$driver = $database['driver'];
if (!$mysql_driver = backdrop_load_database_driver()) {
$errors['driver'] = st("In your %settings_file file you have configured @profile to use a %driver server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@profile' => backdrop_install_profile_distribution_name(), '%driver' => $driver));
}
else {
// Run driver specific validation
$errors += $mysql_driver->validateDatabaseSettings($database);
// Run tasks associated with the database type. Any errors are caught in the
// calling function.
$databases['default']['default'] = $database;
// Just changing the global doesn't get the new information processed.
// We tell tell the Database class to re-parse $databases.
Database::parseConnectionInfo();
try {
db_run_tasks($driver);
}
catch (DatabaseTaskException $e) {
// 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'] = $e->getMessage();
}
}
return $errors;
}