BUG Fix installer for 4.0 (#58)

This commit is contained in:
Damian Mooyman 2016-10-26 14:24:00 +13:00 committed by Sam Minnée
parent d8aab6383e
commit a5738dbfd1
2 changed files with 9 additions and 4 deletions

View File

@ -1,13 +1,16 @@
<?php
use SilverStripe\Dev\Install\DatabaseAdapterRegistry;
use SilverStripe\PostgreSQL\PostgreSQLDatabaseConfigurationHelper;
// PDO Postgre database
DatabaseAdapterRegistry::register(array(
/** @skipUpgrade */
'class' => 'PostgrePDODatabase',
'module' => 'postgresql',
'title' => 'PostgreSQL 8.3+ (using PDO)',
'helperPath' => dirname(__FILE__).'/code/PostgreSQLDatabaseConfigurationHelper.php',
'helperPath' => __DIR__.'/code/PostgreSQLDatabaseConfigurationHelper.php',
'helperClass' => PostgreSQLDatabaseConfigurationHelper::class,
'supported' => (class_exists('PDO') && in_array('postgresql', PDO::getAvailableDrivers())),
'missingExtensionText' =>
'Either the <a href="http://www.php.net/manual/en/book.pdo.php">PDO Extension</a> or
@ -20,8 +23,10 @@ DatabaseAdapterRegistry::register(array(
DatabaseAdapterRegistry::register(array(
/** @skipUpgrade */
'class' => 'PostgreSQLDatabase',
'module' => 'postgresql',
'title' => 'PostgreSQL 8.3+ (using pg_connect)',
'helperPath' => dirname(__FILE__).'/code/PostgreSQLDatabaseConfigurationHelper.php',
'helperPath' => __DIR__.'/code/PostgreSQLDatabaseConfigurationHelper.php',
'helperClass' => PostgreSQLDatabaseConfigurationHelper::class,
'supported' => function_exists('pg_connect'),
'missingExtensionText' =>
'The <a href="http://php.net/pgsql">pgsql</a> PHP extension is not

View File

@ -20,6 +20,7 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp
/**
* Create a connection of the appropriate type
*
* @skipUpgrade
* @param array $databaseConfig
* @param string $error Error message passed by value
* @return mixed|null Either the connection object, or null if error
@ -31,7 +32,6 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp
$password = empty($databaseConfig['password']) ? '' : $databaseConfig['password'];
$server = $databaseConfig['server'];
/** @skipUpgrade */
try {
switch ($databaseConfig['type']) {
case 'PostgreSQLDatabase':
@ -45,7 +45,7 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp
$conn = @new PDO('postgresql:host='.$server.';dbname=postgres;port=5432', $username, $password);
break;
default:
$error = 'Invalid connection type';
$error = 'Invalid connection type: ' . $databaseConfig['type'];
return null;
}
} catch (Exception $ex) {