From 1a685474e698ce3e90dbae87f6a1f83966d9ef63 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Mon, 29 Nov 2010 04:45:11 +0000 Subject: #851136 by Crell, chx, Damien Tournoud: Make the database autoloading more robust. --- includes/install.inc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'includes/install.inc') diff --git a/includes/install.inc b/includes/install.inc index 2c9810a08..1b7d7a796 100644 --- a/includes/install.inc +++ b/includes/install.inc @@ -254,7 +254,6 @@ function drupal_get_database_types() { // Because we have no registry yet, we need to also include the install.inc // file for the driver explicitly. require_once DRUPAL_ROOT . '/includes/database/database.inc'; - spl_autoload_register('db_autoload'); foreach (file_scan_directory(DRUPAL_ROOT . '/includes/database', '/^[a-z]*$/i', array('recurse' => FALSE)) as $file) { if (file_exists($file->uri . '/database.inc') && file_exists($file->uri . '/install.inc')) { $drivers[$file->filename] = $file->uri; @@ -262,8 +261,7 @@ function drupal_get_database_types() { } foreach ($drivers as $driver => $file) { - $class = 'DatabaseTasks_' . $driver; - $installer = new $class(); + $installer = db_installer_object($driver); if ($installer->installable()) { $databases[$driver] = $installer; } @@ -1248,8 +1246,18 @@ function install_profile_info($profile, $locale = 'en') { * encoding. */ function db_run_tasks($driver) { - $task_class = 'DatabaseTasks_' . $driver; - $DatabaseTasks = new $task_class(); - $DatabaseTasks->runTasks(); + db_installer_object($driver)->runTasks(); return TRUE; } + +/** + * Returns a database installer object. + * + * @param $driver + * The name of the driver. + */ +function db_installer_object($driver) { + Database::loadDriverFile($driver, array('install.inc')); + $task_class = 'DatabaseTasks_' . $driver; + return new $task_class(); +} -- cgit v1.2.3