r85282 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85281‎ | r85282 | r85283 >
Date:21:05, 3 April 2011
Author:yaron
Status:ok (Comments)
Tags:
Comment:
Follow-up to r85173 - restored backwards compatibility (DatabaseBase::newFromType() was only added in MW 1.18)
Modified paths:
  • /trunk/extensions/ExternalData/ED_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ExternalData/ED_Utils.php
@@ -134,15 +134,35 @@
135135 }
136136
137137 $db_type = $edgDBServerType[$server_id];
 138+ $db_server = $edgDBServer[$server_id];
 139+ $db_name = $edgDBName[$server_id];
 140+ $db_username = $edgDBUser[$server_id];
 141+ $db_password = $edgDBPass[$server_id];
 142+
 143+ // DatabaseBase::newFromType() was added in MW 1.18
 144+ if ( method_exists( 'DatabaseBase', 'newFromType' ) ) {
 145+ $db = DatabaseBase::newFromType( $db_type,
 146+ array(
 147+ 'host' => $db_server,
 148+ 'user' => $db_username,
 149+ 'password' => $db_password,
 150+ 'dbname' => $db_name,
 151+ )
 152+ );
 153+ } else {
 154+ if ( $db_type == "mysql" ) {
 155+ $db = new Database( $db_server, $db_username, $db_password, $db_name );
 156+ } elseif ( $db_type == "postgres" ) {
 157+ $db = new DatabasePostgres( $db_server, $db_username, $db_password, $db_name );
 158+ } elseif ( $db_type == "mssql" ) {
 159+ $db = new DatabaseMssql( $db_server, $db_username, $db_password, $db_name );
 160+ } elseif ( $db_type == "oracle" ) {
 161+ $db = new DatabaseOracle( $db_server, $db_username, $db_password, $db_name );
 162+ } else {
 163+ $db = null;
 164+ }
 165+ }
138166
139 - $db = DatabaseBase::newFromType( $db_type,
140 - array(
141 - 'host' => $edgDBServer[$server_id],
142 - 'user' => $edgDBUser[$server_id],
143 - 'password' => $edgDBPass[$server_id],
144 - 'dbname' => $edgDBName[$server_id],
145 - ) );
146 -
147167 if ( $db == null ) {
148168 echo ( wfMsgExt( "externaldata-db-unknown-type", array( 'parse', 'escape' ) ) );
149169 return;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85173Do we really need to reinvent the wheel for DatabaseBase::newFromType() ???reedy23:57, 1 April 2011

Comments

#Comment by 😂 (talk | contribs)   16:23, 18 April 2011

Actually it was backported to 1.17 as well ;-)

#Comment by Reedy (talk | contribs)   16:23, 18 April 2011

Though I'd guess they still need the 1.16 (and possibly 1.15, ugh) compat :/

Status & tagging log