Index: config/index.php
===================================================================
--- config/index.php	(revision 25051)
+++ config/index.php	(working copy)
@@ -52,21 +52,6 @@
 # all the details
 $wgShowExceptionDetails = true;
 
-## Databases we support:
-
-$ourdb = array();
-$ourdb['mysql']['fullname']      = 'MySQL';
-$ourdb['mysql']['havedriver']    = 0;
-$ourdb['mysql']['compile']       = 'mysql';
-$ourdb['mysql']['bgcolor']       = '#ffe5a7';
-$ourdb['mysql']['rootuser']      = 'root';
-
-$ourdb['postgres']['fullname']   = 'PostgreSQL';
-$ourdb['postgres']['havedriver'] = 0;
-$ourdb['postgres']['compile']    = 'pgsql';
-$ourdb['postgres']['bgcolor']    = '#aaccff';
-$ourdb['postgres']['rootuser']   = 'postgres';
-
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
@@ -163,11 +148,10 @@
 	<script type="text/javascript">
 	<!--
 	function hideall() {
-		<?php foreach (array_keys($ourdb) as $db) {
-		echo "\n		document.getElementById('$db').style.display='none';";
-		}
+		<?php
+		foreach( $databases as $name => $info )
+			echo( "\ndocument.getElementById( '{$info}' ).style.display = 'none';" );
 		?>
-
 	}
 	function toggleDBarea(id,defaultroot) {
 		hideall();
@@ -175,9 +159,10 @@
 		dbarea.display = (dbarea.display == 'none') ? 'block' : 'none';
 		var db = document.getElementById('RootUser');
 		if (defaultroot) {
-<?php foreach (array_keys($ourdb) as $db) {
-			echo "			if (id == '$db') { db.value = '".$ourdb[$db]['rootuser']."';}\n";
-}?>
+		<?php
+		foreach( $databases as $name => $info )
+			echo( "if( id == '{$name}' ) { db.value = '{$info['rootuser']}'; }\n" );
+		?>
 		}
 	}
 	// -->
@@ -291,40 +276,35 @@
 
 print "<li>PHP " . phpversion() . " installed</li>\n";
 
-error_reporting( 0 );
-$phpdatabases = array();
-foreach (array_keys($ourdb) as $db) {
-	$compname = $ourdb[$db]['compile'];
-	if (extension_loaded($compname) or dl($compname . '.' . PHP_SHLIB_SUFFIX)) {
-		array_push($phpdatabases, $db);
-		$ourdb[$db]['havedriver'] = 1;
-	}
+$databases = array();
+foreach( mw_available_dbs() as $name => $info ) {
+	if( $info['havedriver'] )
+		$databases[$name] = $info;
 }
-error_reporting( E_ALL );
-
-if (!$phpdatabases) {
+if( count( $databases ) > 0 ) {
+	$DefaultDBtype = '';
+	print "<li>Found database drivers for:";
+	foreach( $databases as $name => $info ) {
+		print " {$info['fullname']}";
+		if( $DefaultDBtype == '' )
+			$DefaultDBtype = $name;
+	}
+	print "</li>";
+} else {
 	print "Could not find a suitable database driver!<ul>";
-	foreach (array_keys($ourdb) AS $db) {
-		$comp = $ourdb[$db]['compile'];
-		$full = $ourdb[$db]['fullname'];
-		print "<li>For <b>$full</b>, compile PHP using <b>--with-$comp</b>, "
-			."or install the $comp.so module</li>\n";
+	foreach( mw_available_dbs() as $name => $info ) {
+		print "For <b>{$info['fullname']}</b>, ";
+		if( PHP_SHLIB_SUFFIX === 'dll' ) {
+			print "enable the <tt>php_{$info['compile']}.dll</tt> extension in PHP.ini";
+		} else {
+			print "compile PHP using <tt>--with--{$info['compile']}</tt>, or enable the
+				<tt>{$info['compile']}.so</tt> module in PHP.ini";
+		}
+		print "</li>";
 	}
 	dieout( "</ul></ul>" );
 }
 
-print "<li>Found database drivers for:";
-$DefaultDBtype = '';
-foreach (array_keys($ourdb) AS $db) {
-	if ($ourdb[$db]['havedriver']) {
-		if ( $DefaultDBtype == '' ) {
-			$DefaultDBtype = $db;
-		}
-		print "  ".$ourdb[$db]['fullname'];
-	}
-}
-print "</li>\n";
-
 if( ini_get( "register_globals" ) ) {
 	?>
 	<li>
@@ -723,9 +703,9 @@
 				"</ul>" );
 		}
 		$conf->DBtypename = '';
-		foreach (array_keys($ourdb) as $db) {
-			if ($conf->DBtype === $db)
-				$conf->DBtypename = $ourdb[$db]['fullname'];
+		foreach( $databases as $name => $info ) {
+			if( $conf->DBtype === $name )
+				$conf->DBtypename = $info['fullname'];
 		}
 		if ( ! strlen($conf->DBtype)) {
 			$errs["DBpicktype"] = "Please choose a database type";
@@ -1848,22 +1828,20 @@
 }
 
 function database_picker($conf) {
-	global $ourdb;
+	global $databases;
 	print "\n";
-	foreach(array_keys($ourdb) as $db) {
-		if ($ourdb[$db]['havedriver']) {
-			print "<li>";
-			aField( $conf, "DBtype", $ourdb[$db]['fullname'], 'radio', $db, 'onclick');
-			print "</li>\n";
-		}
+	foreach( $databases as $name => $info ) {
+		print "<li>";
+		aField( $conf, "DBtype", $info['fullname'], 'radio', $name, 'onclick');
+		print "</li>\n";
 	}
 	print "\n";
 }
 
 function database_switcher($db) {
-	global $ourdb;
-	$color = $ourdb[$db]['bgcolor'];
-	$full = $ourdb[$db]['fullname'];
+	$databases = mw_available_dbs();
+	$color = $databases[$db]['bgcolor'];
+	$full = $databases[$db]['fullname'];
 	print "<fieldset id='$db'><legend>$full specific options</legend>\n";
 }
 
Index: install-utils.inc
===================================================================
--- install-utils.inc	(revision 25051)
+++ install-utils.inc	(working copy)
@@ -124,4 +124,58 @@
 	return $path;
 }
 
-?>
+/**
+ * Get information about the database drivers we support, and
+ * whether or not these are available
+ *
+ * @return array
+ */
+function mw_available_dbs() {
+	static $dbs = false;
+	if( $dbs === false ) {
+		$old = error_reporting( 0 ); // Suppress warnings and errors during detection
+		$dbs = array(
+			'mysql' => array(
+				'fullname' => 'MySQL',
+				'compile' => 'mysql',
+				'rootuser' => 'root',
+				'bgcolor' => '#ffe5a7',
+				'havedriver' => mw_have_db_driver( 'mysql' ),
+			),
+			'postgres' => array(
+				'fullname' => 'PostgreSQL',
+				'compile' => 'pgsql',
+				'rootuser' => 'postgres',
+				'bgcolor' => '#aaccff',
+				'havedriver' => mw_have_db_driver( 'pgsql' ),
+			),
+		);
+		error_reporting( $old );
+	}
+	return $dbs;
+}
+
+/**
+ * Is a named database driver available?
+ *
+ * @param string $driver Driver name
+ * @return bool
+ */
+function mw_have_db_driver( $driver ) {
+	return extension_loaded( $driver ) || ( mw_have_dl() && dl( "{$driver}." . PHP_SHLIB_SUFFIX ) );
+}
+
+/**
+ * Is dl() available to us?
+ *
+ * According to http://uk.php.net/manual/en/function.dl.php, dl()
+ * is *not* available when `enable_dl` is off, or under `safe_mode`
+ *
+ * @return bool
+ */
+function mw_have_dl() {
+	return function_exists( 'dl' )
+		&& is_callable( 'dl' )
+		&& ini_get( 'enable_dl' )
+		&& !ini_get( 'safe_mode' );
+}
\ No newline at end of file
