Setting default db adapter in installation as PDO MySQL with MySQLi as fail safe.

Added back missed assignment of $_REQUEST['db']['type']
This commit is contained in:
David Alexander 2016-11-02 18:07:18 +13:00
parent 019e99dd4d
commit 506213899b
3 changed files with 45 additions and 23 deletions

View File

@ -1,26 +1,11 @@
<?php
// Register the SilverStripe provided databases
// Register database adapters available in SilverStripe
use SilverStripe\Dev\Install\DatabaseAdapterRegistry;
use SilverStripe\Dev\Install\MySQLDatabaseConfigurationHelper;
// Use MySQLi as default
DatabaseAdapterRegistry::register(
array(
/** @skipUpgrade */
'class' => 'MySQLDatabase',
'module' => 'framework',
'title' => 'MySQL 5.0+ (using MySQLi)',
'helperPath' => __DIR__ . '/src/Dev/Install/MySQLDatabaseConfigurationHelper.php',
'helperClass' => MySQLDatabaseConfigurationHelper::class,
'supported' => class_exists('MySQLi'),
'missingExtensionText' =>
'The <a href="http://www.php.net/manual/en/book.mysqli.php">MySQLi</a>
PHP extension is not available. Please install or enable it and refresh this page.'
)
);
// Setup MySQL PDO as alternate option
// Register MySQL PDO as a database adapter (listed as first option in Dev/Install/config-form.html)
DatabaseAdapterRegistry::register(
array(
/** @skipUpgrade */
@ -36,3 +21,19 @@ DatabaseAdapterRegistry::register(
are unavailable. Please install or enable these and refresh this page.'
)
);
// Register MySQLi as a database adapter (listed as second option in Dev/Install/config-form.html)
DatabaseAdapterRegistry::register(
array(
/** @skipUpgrade */
'class' => 'MySQLDatabase',
'module' => 'framework',
'title' => 'MySQL 5.0+ (using MySQLi)',
'helperPath' => __DIR__ . '/src/Dev/Install/MySQLDatabaseConfigurationHelper.php',
'helperClass' => MySQLDatabaseConfigurationHelper::class,
'supported' => class_exists('MySQLi'),
'missingExtensionText' =>
'The <a href="http://www.php.net/manual/en/book.mysqli.php">MySQLi</a>
PHP extension is not available. Please install or enable it and refresh this page.'
)
);

View File

@ -183,14 +183,15 @@
</div>
<div class="action">
<input type="submit" class="action" value="Re-check requirements">
</div>
</div>
</div>
<div class="clear"><!-- --></div>
<div class="action">
<input type="submit" class="action" value="Re-check requirements">
</div>
<h3 class="sectionHeading">CMS Admin Account <small>Step 3 of 5</small></h3>
<div id="AdminAccount" class="section">
@ -240,6 +241,10 @@
</div>
</div>
<div class="action">
<input type="submit" class="action" value="Re-check requirements">
</div>
<h3 class="sectionHeading">Theme selection <small>Step 4 of 5</small></h3>
<p class="helpText">You can change the theme or <a href="http://addons.silverstripe.org/add-ons?type=theme">download</a> another from the SilverStripe website after installation.</p>
<ul id="Themes">

View File

@ -142,8 +142,16 @@ if(isset($_REQUEST['db'])) {
if(isset($_REQUEST['db']['type'])) {
$type = $_REQUEST['db']['type'];
} else {
$type = $_REQUEST['db']['type'] = defined('SS_DATABASE_CLASS') ? SS_DATABASE_CLASS : 'MySQLDatabase';
}
if( defined('SS_DATABASE_CLASS') ){
$type = $_REQUEST['db']['type'] = SS_DATABASE_CLASS;
} elseif( $databaseClasses['MySQLPDODatabase']['supported'] ) {
$type = $_REQUEST['db']['type'] = 'MySQLPDODatabase';
} elseif( $databaseClasses['MySQLDatabase']['supported'] ) {
$type = $_REQUEST['db']['type'] = 'MySQLDatabase';
} else {
// handle error
}
}
// Disabled inputs don't submit anything - we need to use the environment (except the database name)
if($usingEnv) {
@ -161,7 +169,15 @@ if(isset($_REQUEST['db'])) {
$databaseConfig['type'] = $type;
}
} else {
$type = $_REQUEST['db']['type'] = defined('SS_DATABASE_CLASS') ? SS_DATABASE_CLASS : 'MySQLDatabase';
if( defined('SS_DATABASE_CLASS') ){
$type = $_REQUEST['db']['type'] = SS_DATABASE_CLASS;
} elseif( $databaseClasses['MySQLPDODatabase']['supported'] ) {
$type = $_REQUEST['db']['type'] = 'MySQLPDODatabase';
} elseif( $databaseClasses['MySQLDatabase']['supported'] ) {
$type = $_REQUEST['db']['type'] = 'MySQLDatabase';
} else {
// handle error
}
$_REQUEST['db'][$type] = $databaseConfig = array(
"type" => $type,
"server" => defined('SS_DATABASE_SERVER') ? SS_DATABASE_SERVER : "localhost",