? sites/default/files
? sites/default/settings.php
Index: install.php
===================================================================
RCS file: /cvs/drupal/drupal/install.php,v
retrieving revision 1.151
diff -u -p -r1.151 install.php
--- install.php	22 Jan 2009 19:31:07 -0000	1.151
+++ install.php	1 Feb 2009 10:03:48 -0000
@@ -370,12 +370,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 <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what any of this means you should probably contact your hosting provider.', array('%commands' => implode($test->success, ', '))));
+    $db_installer->runTasks();
+    if (!empty($db_installer->error)) {
+      if (!empty($db_installer->success)) {
+        form_set_error('db_type', st('<p>In order for Drupal to work, and to continue with the installation process, you must resolve all issues reported below. We were able to do the following:</p> <ul><li>!successful_tasks</li></ul> <p>However, Drupal still needs to be able to complete the following:</p> <ul><li>!failed_tasks</li></ul> <p>For more help with configuring your database server, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what any of this means you should probably contact your hosting provider.</p>', array('!successful_tasks' => implode($db_installer->success, '</li><li>'), '!failed_tasks' => implode($db_installer->error, '</li><li>'))));
       }
       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	1 Feb 2009 10:03:50 -0000
@@ -238,61 +238,116 @@ function drupal_detect_database_types() 
 
   return $databases;
 }
-
+/**
+ * Database installer structure.
+ *
+ * Defines basic drupal requirements for databases.
+ */
 abstract class DatabaseInstaller {
-  protected $success = array();
-  protected $tests = array(
+
+  /**
+   * @var Array to store successful tasks.
+   */
+  public $success = array();
+  
+  /**
+   * @var Array to store failed tasks.
+   */
+  public $error = array();
+
+  /**
+   * @var Keyed array structure that describes each task to run.
+   *
+   * Each key has another keyed array within it, describing the 
+   * function to call and an array or parameters to pass to the 
+   * function.
+   */
+  protected $tasks = array(
+    'testConnect'=> array(
+      'function' => 'testConnect',
+      'params'   => 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.<ul><li>Are you sure the configured username has the necessary %name permissions to create tables in the database?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.',
-      'fatal' => TRUE,
+      'function' => 'runTestQuery',
+      'params'   => array(
+        'query' => 'CREATE TABLE drupal_install_test (id int NULL)',
+        'command'  => 'CREATE',
+        'fail'  => 'Failed to <strong>CREATE</strong> a test table on your %name database server with the command %query. %name reports the following message: %error.<p>Are you sure the configured username has the necessary %name permissions to create tables in the database?</p>',
+        'fatal'    => 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.',
+      'function' => 'runTestQuery',
+      'params'   => array(
+        'query' => 'INSERT INTO drupal_install_test (id) VALUES (1)',
+        'command'  => 'INSERT',
+        'fail'  => 'Failed to <strong>INSERT</strong> 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.',
+      'function' => 'runTestQuery',
+      'params'   => array(
+        'query' => 'UPDATE drupal_install_test SET id = 2',
+        'command'  => 'UPDATE',
+        'fail'  => 'Failed to <strong>UPDATE</strong> 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.',
+      'function' => 'runTestQuery',
+      'params'   => array(
+        'query' => 'DELETE FROM drupal_install_test',
+        'command'  => 'DELETE',
+        'fail'  => 'Failed to <strong>DELETE</strong> 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.',
+      'function' => 'runTestQuery',
+      'params'   => array(
+        'query' => 'DROP TABLE drupal_install_test',
+        'command'  => 'DELETE',
+        'fail'  => 'Failed to <strong>DROP</strong> 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;
 
+  /**
+   * Ensures the PDO driver is supported by version of PHP in use.
+   */
   protected function hasPdoDriver() {
     return in_array($this->pdoDriver, PDO::getAvailableDrivers());
   }
 
+  /**
+   * Check Drupal is installable on 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;
-    }
-    foreach ($this->tests as $test) {
-      $return = $this->runTestQuery($test['query'], $test['success'], $test['message'], !empty($tests['fatal']));
-      if ($return === FALSE) {
-        return FALSE;
+  /**
+   * Run database specfic tasks to ensure Drupal can operate on database environment.
+   *
+   * Called at install to run tests against the database to
+   * make sure Drupal can install ok. Each test should append
+   * a message to the success or error array.
+   */
+  public function runTasks() {
+    foreach ($this->tasks as $task) {
+      $return = null;
+      if (method_exists($this, $task['function'])) {
+        // Returning false is fatal. No other tasls can run.
+        if (FALSE === call_user_func_array(array($this, $task['function']),$task['params'])) {
+          return FALSE;
+        }
+      }
+      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');
+        $return = FALSE;
       }
     }
-    return $this->success;
+    return TRUE;
   }
 
   /**
@@ -304,25 +359,25 @@ abstract class DatabaseInstaller {
   protected function testConnect() {
     try {
       db_set_active();
-      $this->success[] = 'CONNECT';
+      $this->success[] = '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.<ul><li>Are you sure you have the correct username and password?</li><li>Are you sure that you have typed the correct database hostname?</li><li>Are you sure that the database server is running?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%error' => $e->getMessage(), 'name' => $this->name())), 'error');
+      $this->error[] = st('Failed to connect to your %name database server. %name reports the following message: %error.<ul><li>Are you sure you have the correct username and password?</li><li>Are you sure that you have typed the correct database hostname?</li><li>Are you sure that the database server is running?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%error' => $e->getMessage(), 'name' => $this->name()));
       return FALSE;
     }
   }
-
-  protected function runTestQuery($query, $success, $message, $fatal = FALSE) {
+  
+  /**
+   * Run SQL tests to ensure database is a useable environment.
+   */
+  private function runTestQuery($query, $command, $fail, $fatal = FALSE) {
     try {
       db_query($query);
-      $this->success[] = $success;
+      $this->success[] = st("Drupal can use %command commands on the database ok.", array('%command' => $command));
     }
     catch (Exception $e) {
-      drupal_set_message(st($message, array('%query' => $query, '%error' => $e->getMessage(), '%name' => $this->name())), 'error');
-      $this->error = TRUE;
-      if ($fatal) {
-        return FALSE;
-      }
+      $this->error[] = st($fail, array('%query' => $query, '%error' => $e->getMessage(), '%name' => $this->name()));
+      return !$fatal;
     }
   }
 }
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	1 Feb 2009 10:03:50 -0000
@@ -5,8 +5,34 @@
 
 class DatabaseInstaller_pgsql extends DatabaseInstaller {
   protected $pdoDriver = 'pgsql';
+
+  public function __construct() {
+    $this->tasks["checkEncoding"] = array(
+        "function" => "checkEncoding",
+        "params"   => array(
+          "message"  => "Drupal uses %encoding encoding with PostgreSQL however, PostgreSQL is not set to use %encoding encoding. Please create the database with %encoding encoding.", 
+        ),
+      );
+  }
+
   public function name() {
     return 'PostgreSQL';
   }
+
+  /**
+   * Check encoding is UTF8.
+   */
+  protected function checkEncoding($params) {
+    try {
+      if (db_query("SHOW server_encoding")->fetchField() == "UTF8") { 
+        $this->success[] = "Database is encoded in UTF-8";
+      }
+      else {
+        $this->error[] =  st("Drupal uses %encoding encoding with %driver however, %driver is not set to use UTF-8 encoding. Please create the database with %encoding encoding.", array('%driver' => $this->name()));
+      }
+    } catch (Exception $e) {
+      $this->error[] = st("Drupal could not determine the encoding of the database was set to UTF-8");
+    }  
+  }
 }
 
