BUG Fix installer for 4.0 (#29)

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

View File

@ -1,6 +1,7 @@
<?php <?php
use SilverStripe\Dev\Install\DatabaseAdapterRegistry; use SilverStripe\Dev\Install\DatabaseAdapterRegistry;
use SilverStripe\SQLite\SQLiteDatabaseConfigurationHelper;
$sqliteDatabaseAdapterRegistryFields = array( $sqliteDatabaseAdapterRegistryFields = array(
'path' => array( 'path' => array(
@ -19,8 +20,10 @@ $sqliteDatabaseAdapterRegistryFields = array(
DatabaseAdapterRegistry::register( DatabaseAdapterRegistry::register(
array( array(
'class' => 'SQLite3Database', 'class' => 'SQLite3Database',
'module' => 'sqlite3',
'title' => 'SQLite 3.3+ (using SQLite3)', 'title' => 'SQLite 3.3+ (using SQLite3)',
'helperPath' => dirname(__FILE__).'/code/SQLiteDatabaseConfigurationHelper.php', 'helperPath' => __DIR__.'/code/SQLiteDatabaseConfigurationHelper.php',
'helperClass' => SQLiteDatabaseConfigurationHelper::class,
'supported' => class_exists('SQLite3'), 'supported' => class_exists('SQLite3'),
'missingExtensionText' => 'The <a href="http://php.net/manual/en/book.sqlite3.php">SQLite3</a> 'missingExtensionText' => 'The <a href="http://php.net/manual/en/book.sqlite3.php">SQLite3</a>
PHP Extension is not available. Please install or enable it of them and refresh this page.', PHP Extension is not available. Please install or enable it of them and refresh this page.',
@ -37,8 +40,10 @@ DatabaseAdapterRegistry::register(
DatabaseAdapterRegistry::register( DatabaseAdapterRegistry::register(
array( array(
'class' => 'SQLite3PDODatabase', 'class' => 'SQLite3PDODatabase',
'module' => 'sqlite3',
'title' => 'SQLite 3.3+ (using PDO)', 'title' => 'SQLite 3.3+ (using PDO)',
'helperPath' => dirname(__FILE__).'/code/SQLiteDatabaseConfigurationHelper.php', 'helperPath' => __DIR__.'/code/SQLiteDatabaseConfigurationHelper.php',
'helperClass' => SQLiteDatabaseConfigurationHelper::class,
'supported' => (class_exists('PDO') && in_array('sqlite', PDO::getAvailableDrivers())), 'supported' => (class_exists('PDO') && in_array('sqlite', PDO::getAvailableDrivers())),
'missingExtensionText' => 'missingExtensionText' =>
'Either the <a href="http://php.net/manual/en/book.pdo.php">PDO Extension</a> or the 'Either the <a href="http://php.net/manual/en/book.pdo.php">PDO Extension</a> or the

View File

@ -20,6 +20,7 @@ class SQLiteDatabaseConfigurationHelper implements DatabaseConfigurationHelper
/** /**
* Create a connection of the appropriate type * Create a connection of the appropriate type
* *
* @skipUpgrade
* @param array $databaseConfig * @param array $databaseConfig
* @param string $error Error message passed by value * @param string $error Error message passed by value
* @return mixed|null Either the connection object, or null if error * @return mixed|null Either the connection object, or null if error
@ -27,7 +28,6 @@ class SQLiteDatabaseConfigurationHelper implements DatabaseConfigurationHelper
protected function createConnection($databaseConfig, &$error) protected function createConnection($databaseConfig, &$error)
{ {
$error = null; $error = null;
/** @skipUpgrade */
try { try {
if (!file_exists($databaseConfig['path'])) { if (!file_exists($databaseConfig['path'])) {
self::create_db_dir($databaseConfig['path']); self::create_db_dir($databaseConfig['path']);
@ -49,7 +49,7 @@ class SQLiteDatabaseConfigurationHelper implements DatabaseConfigurationHelper
$conn = @new PDO("sqlite:$file"); $conn = @new PDO("sqlite:$file");
break; break;
default: default:
$error = 'Invalid connection type'; $error = 'Invalid connection type: ' . $databaseConfig['type'];
return null; return null;
} }