Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.150 diff -u -p -r1.150 install.php --- install.php 20 Jan 2009 03:18:40 -0000 1.150 +++ install.php 20 Jan 2009 10:26:39 -0000 @@ -369,12 +369,12 @@ function _install_settings_form_validate form_set_value($form['_database'], $database, $form_state); } $class = "DatabaseInstaller_$driver"; - $test = new $class; + $db_installer = new $class; $databases = array('default' => array('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, ', ')))); + $return = $db_installer->runTasks(); + if (!$return || $db_installer->error) { + if (!empty($db_installer->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($db_installer->success, ', ')))); } else { form_set_error('driver', ''); Index: includes/install.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/install.inc,v retrieving revision 1.82 diff -u -p -r1.82 install.inc --- includes/install.inc 18 Jan 2009 06:56:58 -0000 1.82 +++ includes/install.inc 20 Jan 2009 10:26:41 -0000 @@ -238,33 +238,50 @@ function drupal_detect_database_types() return $databases; } - +/** + * Database installer structure. + * + * Defines basic drupal requirements for databases. + */ abstract class DatabaseInstaller { + + /** + * @var Array to store successful tasks + */ protected $success = array(); - protected $tests = array( + + /** + * @var Keyed array structure that describes task to run. + * Each key has another keyed array describing the kind + * of task. There are two types of tasks, querys and + * functions. Query types have the additional 'query' key + * with SQL to execute and functions have the 'function' + * key with the callback function to call. + */ + protected $tasks = array( 'testCreate' => array( - 'query' => 'CREATE TABLE drupal_install_test (id int NULL)', + '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.For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.', - 'fatal' => TRUE, + 'fatal' => TRUE, ), 'testInsert' => array( - 'query' => 'INSERT INTO drupal_install_test (id) VALUES (1)', + '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.', ), 'testUpdate' => array( - 'query' => 'UPDATE drupal_install_test SET id = 2', + '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.', ), 'testDelete' => array( - 'query' => 'DELETE FROM drupal_install_test', + '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.', ), 'testDrop' => array( - 'query' => 'DROP TABLE drupal_install_test', + '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.', ), @@ -281,13 +298,19 @@ abstract class DatabaseInstaller { abstract public function name(); - public function test() { + public function runTasks() { $return = $this->testConnect(); if ($return === FALSE) { return FALSE; } - foreach ($this->tests as $test) { - $return = $this->runTestQuery($test['query'], $test['success'], $test['message'], !empty($tests['fatal'])); + foreach ($this->tasks as $task) { + // Check if task is a function otherwise assume its a query. + if (isset($task['function']) && method_exists($this, $task['function'])) { + $return = $this->$task['function']($task['success'], $task['message']); + } + else { + $return = $this->runTestQuery($task['query'], $task['success'], $task['message'], !empty($task['fatal'])); + } if ($return === FALSE) { return FALSE; } Index: includes/database/pgsql/install.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database/pgsql/install.inc,v retrieving revision 1.1 diff -u -p -r1.1 install.inc --- includes/database/pgsql/install.inc 21 Aug 2008 19:36:36 -0000 1.1 +++ includes/database/pgsql/install.inc 20 Jan 2009 10:26:41 -0000 @@ -5,8 +5,42 @@ class DatabaseInstaller_pgsql extends DatabaseInstaller { protected $pdoDriver = 'pgsql'; + + public function __construct() { + $this->tasks = array_merge( + array( + "checkEncoding" => array( + "function" => "checkEncoding", + "success" => "ENCODING", + "message" => "Drupal uses %encoding encoding with PostgreSQL however, PostgreSQL is not set to use %encoding encoding. Please create the database with %encoding encoding.", + ), + ), + $this->tasks + ); + } + public function name() { return 'PostgreSQL'; } + + /** + * Check encoding is UTF8. + */ + protected function checkEncoding($success, $message) { + try { + if (db_result(db_query("SHOW server_encoding")) == "UTF8") { + $this->success[] = $success; + return TRUE; + } + else { + drupal_set_message(st($message, array('%encoding' => "UTF-8", )), 'error'); + return FALSE; + } + } catch (Exception $e) { + drupal_set_message(st("Drupal could not determine the encoding of the database was set to %encoding", array('%encoding' => "UTF-8", )), 'error'); + $this->error = TRUE; + return FALSE; + } + } }