r105148 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105147‎ | r105148 | r105149 >
Date:03:22, 5 December 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added support for MW 1.18+: DatabaseBase::newFromType() was replaced with DatabaseBase::factory() in MW 1.18
Modified paths:
  • /trunk/extensions/ExternalData/ED_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ExternalData/ED_Utils.php
@@ -178,9 +178,25 @@
179179 $db_tableprefix = '';
180180 }
181181
182 - // DatabaseBase::newFromType() was added in MW 1.17
183 - $realFunction = array( 'DatabaseBase', 'newFromType' );
184 - if ( is_callable( $realFunction ) ) {
 182+ // DatabaseBase::newFromType() was added in MW 1.17 - it was
 183+ // then replaced by DatabaseBase::factory() in MW 1.18
 184+ $factorFunction = array( 'DatabaseBase', 'factory' );
 185+ $newFromTypeFunction = array( 'DatabaseBase', 'newFromType' );
 186+ if ( is_callable( $factorFunction ) ) {
 187+ $db = DatabaseBase::factory( $db_type,
 188+ array(
 189+ 'host' => $db_server,
 190+ 'user' => $db_username,
 191+ 'password' => $db_password,
 192+ // Both 'dbname' and 'dbName' have been
 193+ // used in different versions.
 194+ 'dbname' => $db_name,
 195+ 'dbName' => $db_name,
 196+ 'flags' => $db_flags,
 197+ 'tablePrefix' => $db_tableprefix,
 198+ )
 199+ );
 200+ } elseif ( is_callable( $newFromTypeFunction ) ) {
185201 $db = DatabaseBase::newFromType( $db_type,
186202 array(
187203 'host' => $db_server,

Status & tagging log