From bb61a0486e0657f366a77e34593ea9540d12c8a7 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 15 Jun 2015 18:15:28 +0100 Subject: [PATCH] database: Don't treat $defaultSchemas as containing all types/drivers The Database::factory() method treats $dbType as of one of predefined "canonicalDBTypes", and defaults to using it as driver. Which is then used for the name of the Database subclass. This allows extensions and wiki farms to have custom subclasses to override certain methods, or even provide new drivers. The $defaultSchemas array added in f7174057a4 was given all canonical keys (with null values) to allow unconditionally access. This doesn't scale very well and is error-prone. Reduce it to the override only and fallback make the fallback to null explicitly. See T102285 for where this would help prevent a PHP Notice. Change-Id: I3f1e1f59c300d34de30f6480ff4e54f159d51b16 --- includes/db/Database.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index e15c248ca9..94cf1f2c3e 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -915,10 +915,6 @@ abstract class DatabaseBase implements IDatabase { // Although postgres and oracle support schemas, we don't use them (yet) // to maintain backwards compatibility $defaultSchemas = array( - 'mysql' => null, - 'postgres' => null, - 'sqlite' => null, - 'oracle' => null, 'mssql' => 'get from global', ); @@ -932,7 +928,9 @@ abstract class DatabaseBase implements IDatabase { $p['flags'] = isset( $p['flags'] ) ? $p['flags'] : 0; $p['variables'] = isset( $p['variables'] ) ? $p['variables'] : array(); $p['tablePrefix'] = isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : 'get from global'; - $p['schema'] = isset( $p['schema'] ) ? $p['schema'] : $defaultSchemas[$dbType]; + if ( !isset( $p['schema'] ) ) { + $p['schema'] = isset( $defaultSchemas[$dbType] ) ? $defaultSchemas[$dbType] : null; + } $p['foreign'] = isset( $p['foreign'] ) ? $p['foreign'] : false; return new $class( $p ); -- 2.20.1