By sun on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Issue links:
Description:
global $databases has been removed in favor of the preexisting static connection info management methods on the Database class.
Drupal 7
global $databases;
// Check whether we have a default connection.
$has_connection = !empty($databases['default']['default']);
Drupal 8
use Drupal\Core\Database\Database;
$has_connection = (bool) Database::getConnectionInfo('default');
All code should already use the Database connection info methods to dynamically add/rename/remove connections. Additional manual manipulations of global $databases were only needed in edge-case situations — those manipulations can be removed now.
Impacts:
Module developers