r86528 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86527‎ | r86528 | r86529 >
Date:19:07, 20 April 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added support for new $edgDBFlags and $edgDBTablePrefix global variables, with patch from Solitarius
Modified paths:
  • /trunk/extensions/ExternalData/ED_Utils.php (modified) (history)
  • /trunk/extensions/ExternalData/ExternalData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ExternalData/ExternalData.php
@@ -48,6 +48,8 @@
4949 $edgDBName = array();
5050 $edgDBUser = array();
5151 $edgDBPass = array();
 52+$edgDBFlags = array();
 53+$edgDBTablePrefix = array();
5254
5355 function edgRegisterParser( &$parser ) {
5456 $parser->setFunctionHook( 'get_external_data', array( 'EDParserFunctions', 'doGetExternalData' ) );
Index: trunk/extensions/ExternalData/ED_Utils.php
@@ -133,7 +133,10 @@
134134 global $edgDBName;
135135 global $edgDBUser;
136136 global $edgDBPass;
 137+ global $edgDBFlags;
 138+ global $edgDBTablePrefix;
137139
 140+ // Mandatory parameters
138141 if ( ( ! array_key_exists( $server_id, $edgDBServerType ) ) ||
139142 ( ! array_key_exists( $server_id, $edgDBServer ) ) ||
140143 ( ! array_key_exists( $server_id, $edgDBName ) ) ||
@@ -149,7 +152,19 @@
150153 $db_username = $edgDBUser[$server_id];
151154 $db_password = $edgDBPass[$server_id];
152155
153 - // DatabaseBase::newFromType() was added in MW 1.18
 156+ // Optional parameters
 157+ if ( array_key_exists( $server_id, $edgDBFlags ) ) {
 158+ $db_flags = $edgDBFlags[$server_id];
 159+ } else {
 160+ $db_flags = DBO_DEFAULT;
 161+ }
 162+ if ( array_key_exists( $server_id, $edgDBTablePrefix ) ) {
 163+ $db_tableprefix = $edgDBTablePrefix[$server_id];
 164+ } else {
 165+ $db_tableprefix = '';
 166+ }
 167+
 168+ // DatabaseBase::newFromType() was added in MW 1.17
154169 $realFunction = array( 'DatabaseBase', 'newFromType' );
155170 if ( is_callable( $realFunction ) ) {
156171 $db = DatabaseBase::newFromType( $db_type,
@@ -158,9 +173,16 @@
159174 'user' => $db_username,
160175 'password' => $db_password,
161176 'dbname' => $db_name,
 177+ 'flags' => $db_flags,
 178+ 'tableprefix' => $db_tableprefix,
162179 )
163180 );
164181 } else {
 182+ if ( ( $db_flags !== DBO_DEFAULT ) || ( $db_tableprefix !== '' ) ) {
 183+ print wfMsg( "externaldata-db-option-unsupported", '<code>$edgDBFlags</code>', '<code>$edgDBTablePrefix</code>' );
 184+ return;
 185+ }
 186+
165187 if ( $db_type == "mysql" ) {
166188 $db = new Database( $db_server, $db_username, $db_password, $db_name );
167189 } elseif ( $db_type == "postgres" ) {

Status & tagging log