? sites/default/files ? sites/default/settings.php Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.174 diff -u -p -r1.174 install.php --- install.php 28 May 2009 08:34:14 -0000 1.174 +++ install.php 1 Jun 2009 01:13:50 -0000 @@ -362,17 +362,11 @@ function _install_settings_form_validate if (isset($form)) { form_set_value($form['_database'], $database, $form_state); } - $class = "DatabaseInstaller_$driver"; - $test = new $class; - $databases['default']['default'] = $database; - $return = $test->test(); - if (!$return || $test->error) { - if (!empty($test->success)) { - form_set_error('db_type', st('In order for Drupal to work, and to continue with the installation process, you must resolve all permission issues reported above. We were able to verify that we have permission for the following commands: %commands. For more help with configuring your database server, see the Installation and upgrading handbook. If you are unsure what any of this means you should probably contact your hosting provider.', array('%commands' => implode($test->success, ', ')))); - } - else { - form_set_error('driver', ''); - } + try { + db_run_tasks(); + } + catch (DatabaseInstallerException $e) { + form_set_error('db_type', $e->getMessage()); } } } Index: includes/install.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/install.inc,v retrieving revision 1.91 diff -u -p -r1.91 install.inc --- includes/install.inc 24 May 2009 17:39:30 -0000 1.91 +++ includes/install.inc 1 Jun 2009 01:13:52 -0000 @@ -222,7 +222,7 @@ function drupal_detect_database_types() } foreach ($drivers as $driver => $file) { - $class = 'DatabaseInstaller_' . $driver; + $class = 'DatabaseTasks_' . $driver; $installer = new $class(); if ($installer->installable()) { $databases[$driver] = $installer->name(); @@ -239,60 +239,130 @@ function drupal_detect_database_types() return $databases; } -abstract class DatabaseInstaller { - protected $success = array(); - protected $tests = array( - 'testCreate' => array( - 'query' => 'CREATE TABLE drupal_install_test (id int NULL)', - 'success' => 'CREATE', - 'message' => 'Failed to create a test table on your %name database server with the command %query. %name reports the following message: %error.
Are you sure the configured username has the necessary %name permissions to create tables in the database?
', + TRUE, + ), ), - 'testInsert' => array( - 'query' => 'INSERT INTO drupal_install_test (id) VALUES (1)', - 'success' => 'INSERT', - 'message' => 'Failed to insert a value into a test table on your %name database server. We tried inserting a value with the command %query and %name reported the following error: %error.', + array( + 'arguments' => array( + 'INSERT INTO drupal_install_test (id) VALUES (1)', + 'Drupal can use INSERT database commands.', + 'Failed to INSERT a value into a test table on your %name database server. We tried inserting a value with the command %query and %name reported the following error: %error.', + ), ), - 'testUpdate' => array( - 'query' => 'UPDATE drupal_install_test SET id = 2', - 'success' => 'UPDATE', - 'message' => 'Failed to update a value in a test table on your %name database server. We tried updating a value with the command %query and %name reported the following error: %error.', + array( + 'arguments' => array( + 'UPDATE drupal_install_test SET id = 2', + 'Drupal can use UPDATE database commands.', + 'Failed to UPDATE a value in a test table on your %name database server. We tried updating a value with the command %query and %name reported the following error: %error.', + ), ), - 'testDelete' => array( - 'query' => 'DELETE FROM drupal_install_test', - 'success' => 'DELETE', - 'message' => 'Failed to delete a value from a test table on your %name database server. We tried deleting a value with the command %query and %name reported the following error: %error.', + array( + 'arguments' => array( + 'DELETE FROM drupal_install_test', + 'Drupal can use DELETE database commands.', + 'Failed to DELETE a value from a test table on your %name database server. We tried deleting a value with the command %query and %name reported the following error: %error.', + ), ), - 'testDrop' => array( - 'query' => 'DROP TABLE drupal_install_test', - 'success' => 'DELETE', - 'message' => 'Failed to drop a test table from your %name database server. We tried dropping a table with the command %query and %name reported the following error %error.', + array( + 'arguments' => array( + 'DROP TABLE drupal_install_test', + 'Drupal can use DROP TABLE database commands.', + 'Failed to DROP a test table from your %name database server. We tried dropping a table with the command %query and %name reported the following error %error.', + ), ), ); - public $error = FALSE; + /** + * Results from tasks. + * + * @var array + */ + protected $results = array(); + + /** + * Ensure the PDO driver is supported by the version of PHP in use. + */ protected function hasPdoDriver() { return in_array($this->pdoDriver, PDO::getAvailableDrivers()); } + /** + * Assert test as failed. + */ + protected function fail($message) { + $this->results[$message] = FALSE; + } + + /** + * Assert test as a pass. + */ + protected function pass($message) { + $this->results[$message] = TRUE; + } + + /** + * Check whether Drupal is installable on the database. + */ public function installable() { - return $this->hasPdoDriver(); + return $this->hasPdoDriver() && empty($this->error); } abstract public function name(); - public function test() { - $return = $this->testConnect(); - if ($return === FALSE) { - return FALSE; + /** + * Run database tasks and tests to see if Drupal can run on the database. + */ + public function runTasks() { + foreach ($this->tasks as $task) { + if (!isset($task['function'])) { + $task['function'] = 'runTestQuery'; + } + if (method_exists($this, $task['function'])) { + // Returning false is fatal. No other tasks can run. + if (FALSE === call_user_func_array(array($this, $task['function']), $task['arguments'])) { + break; + } + } + else { + drupal_set_message(st('Failed to run all tasks against the database server. The task %task wasn\'t found.', array('%task' => $task['function'])), 'error'); + } } - foreach ($this->tests as $test) { - $return = $this->runTestQuery($test['query'], $test['success'], $test['message'], !empty($tests['fatal'])); - if ($return === FALSE) { - return FALSE; + // Check for failed results and compile message + $message = ''; + foreach ($this->results as $result => $success) { + if (!$success) { + $message .= '' . $result . '
'; } } - return $this->success; + if (!empty($message)) { + $message = 'In order for Drupal to work, and to continue with the installation process, you must resolve all permission issues reported below. For more help with configuring your database server, see the Installation and upgrading handbook. If you are unsure what any of this means you should probably contact your hosting provider.
' . $message; + throw new DatabaseTaskException($message); + } } /** @@ -304,30 +374,36 @@ abstract class DatabaseInstaller { protected function testConnect() { try { db_set_active(); - $this->success[] = 'CONNECT'; + $this->pass('Drupal can CONNECT to the database ok.'); } catch (Exception $e) { - drupal_set_message(st('Failed to connect to your %name database server. %name reports the following message: %error.