1 bootstrap.inc | backdrop_bootstrap_is_installed() |
Verify the installation of Backdrop is correct.
This is called when an uncaught exception is thrown during the initial bootstrap process. The most common misconfiguration is pointing Backdrop at an empty database. If this happens, redirect the user to install.php.
File
- core/
includes/ bootstrap.inc, line 2955 - Functions that need to be loaded on every Backdrop request.
Code
function backdrop_bootstrap_is_installed() {
// We may get a situation where the config directory has been specified in
// settings.php but the database is empty. In which case a config exception
// is thrown in the first bootstrap phase but the database hasn't been loaded.
// Skip to loading the database and try checking if it's empty.
if (backdrop_get_bootstrap_phase() < BACKDROP_BOOTSTRAP_DATABASE) {
try {
_backdrop_bootstrap_database();
// Getting a connection the first time opens it and populates the
// $GLOBALS['databases'] variable.
Database::getConnection('default');
}
catch (Exception $e) {
}
}
if (empty($GLOBALS['databases'])) {
return FALSE;
}
elseif (function_exists('db_query')) {
try {
db_query('SELECT name FROM {system} WHERE name = :name', array(':name' => 'system'));
}
catch (PDOException $e) {
// System table not found.
if ($e->getCode() == '42S02') {
return FALSE;
}
}
}
return TRUE;
}