BUG Fix _configure_database.php being ignored

Fixes #7590
This commit is contained in:
Damian Mooyman 2017-11-21 17:13:08 +13:00
parent 5bfc0c43eb
commit 9666222637
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
4 changed files with 18 additions and 7 deletions

View File

@ -52,9 +52,9 @@
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"silverstripe/versioned": "^1.0@dev",
"silverstripe/versioned": "^1.0",
"silverstripe/behat-extension": "^3",
"silverstripe/serve": "dev-master",
"silverstripe/serve": "^2",
"se/selenium-server-standalone": "2.41.0"
},
"provide": {

View File

@ -359,7 +359,7 @@ class CoreKernel implements Kernel
}
// Allow database adapters to handle their own configuration
DatabaseAdapterRegistry::autoconfigure();
DatabaseAdapterRegistry::autoconfigure($databaseConfig);
return $databaseConfig;
}

View File

@ -3,6 +3,7 @@
namespace SilverStripe\Dev\Install;
use InvalidArgumentException;
use SilverStripe\Dev\Deprecation;
/**
* This class keeps track of the available database adapters
@ -131,10 +132,19 @@ class DatabaseAdapterRegistry
* Called by ConfigureFromEnv.php.
* Searches through vendor/ folder only,
* does not support "legacy" folder location in webroot
*
* @param array $config Config to update. If not provided fall back to global $databaseConfig.
* In 5.0.0 this will be mandatory and the global will be removed.
*/
public static function autoconfigure()
public static function autoconfigure(&$config = null)
{
// Search through all composer packages in vendor
if (!isset($config)) {
Deprecation::notice('5.0', 'Configuration via global is deprecated');
global $databaseConfig;
} else {
$databaseConfig = $config;
}
// Search through all composer packages in vendor, updating $databaseConfig
foreach (glob(BASE_PATH . '/vendor/*', GLOB_ONLYDIR) as $vendor) {
foreach (glob($vendor . '/*', GLOB_ONLYDIR) as $directory) {
if (file_exists($directory . '/_configure_database.php')) {
@ -142,6 +152,8 @@ class DatabaseAdapterRegistry
}
}
}
// Update modified variable
$config = $databaseConfig;
}
/**

View File

@ -899,8 +899,7 @@ abstract class DBSchemaManager
*
* @param string $tableName The name of the table.
* @param string $indexName The name of the index.
* @param string $indexSpec The specification of the index, see {@link SS_Database::requireIndex()}
* for more details.
* @param array $indexSpec The specification of the index, see Database::requireIndex() for more details.
* @todo Find out where this is called from - Is it even used? Aren't indexes always dropped and re-added?
*/
abstract public function alterIndex($tableName, $indexName, $indexSpec);