r86737 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86736‎ | r86737 | r86738 >
Date:20:27, 22 April 2011
Author:yaron
Status:deferred
Tags:
Comment:
Renamed 'server' parameter in #get_db_data to 'db' - better reflects the nature of the parameter (old one also kept, for backward compatibility)
Modified paths:
  • /trunk/extensions/ExternalData/ED_ParserFunctions.php (modified) (history)
  • /trunk/extensions/ExternalData/ED_Utils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ExternalData/ED_ParserFunctions.php
@@ -215,7 +215,12 @@
216216 array_shift( $params ); // we already know the $parser ...
217217 $args = EDUtils::parseParams( $params ); // parse params into name-value pairs
218218 $data = ( array_key_exists( 'data', $args ) ) ? $args['data'] : null;
219 - $server = ( array_key_exists( 'server', $args ) ) ? $args['server'] : null;
 219+ $dbID = ( array_key_exists( 'db', $args ) ) ? $args['db'] : null;
 220+ // For backwards-compatibility - 'db' parameter was added
 221+ // in External Data version 1.3.
 222+ if ( is_null( $dbID ) ) {
 223+ $dbID = ( array_key_exists( 'server', $args ) ) ? $args['server'] : null;
 224+ }
220225 $table = ( array_key_exists( 'from', $args ) ) ? $args['from'] : null;
221226 $conds = ( array_key_exists( 'where', $args ) ) ? $args['where'] : null;
222227 $limit = ( array_key_exists( 'limit', $args ) ) ? $args['limit'] : null;
@@ -223,7 +228,7 @@
224229 $options = array( 'LIMIT' => $limit, 'ORDER BY' => $orderBy );
225230 $mappings = EDUtils::paramToArray( $data ); // parse the data arg into mappings
226231
227 - $external_values = EDUtils::getDBData( $server, $table, array_values( $mappings ), $conds, $options );
 232+ $external_values = EDUtils::getDBData( $dbID, $table, array_values( $mappings ), $conds, $options );
228233 // handle error cases
229234 if ( is_null( $external_values ) )
230235 return;
Index: trunk/extensions/ExternalData/ED_Utils.php
@@ -141,7 +141,7 @@
142142 return $results;
143143 }
144144
145 - static function getDBData( $server_id, $from, $columns, $where, $options ) {
 145+ static function getDBData( $dbID, $from, $columns, $where, $options ) {
146146 global $edgDBServerType;
147147 global $edgDBServer;
148148 global $edgDBName;
@@ -151,29 +151,29 @@
152152 global $edgDBTablePrefix;
153153
154154 // Mandatory parameters
155 - if ( ( ! array_key_exists( $server_id, $edgDBServerType ) ) ||
156 - ( ! array_key_exists( $server_id, $edgDBServer ) ) ||
157 - ( ! array_key_exists( $server_id, $edgDBName ) ) ||
158 - ( ! array_key_exists( $server_id, $edgDBUser ) ) ||
159 - ( ! array_key_exists( $server_id, $edgDBPass ) ) ) {
 155+ if ( ( ! array_key_exists( $dbID, $edgDBServerType ) ) ||
 156+ ( ! array_key_exists( $dbID, $edgDBServer ) ) ||
 157+ ( ! array_key_exists( $dbID, $edgDBName ) ) ||
 158+ ( ! array_key_exists( $dbID, $edgDBUser ) ) ||
 159+ ( ! array_key_exists( $dbID, $edgDBPass ) ) ) {
160160 echo ( wfMsgExt( "externaldata-db-incomplete-information", array( 'parse', 'escape' ) ) );
161161 return;
162162 }
163163
164 - $db_type = $edgDBServerType[$server_id];
165 - $db_server = $edgDBServer[$server_id];
166 - $db_name = $edgDBName[$server_id];
167 - $db_username = $edgDBUser[$server_id];
168 - $db_password = $edgDBPass[$server_id];
 164+ $db_type = $edgDBServerType[$dbID];
 165+ $db_server = $edgDBServer[$dbID];
 166+ $db_name = $edgDBName[$dbID];
 167+ $db_username = $edgDBUser[$dbID];
 168+ $db_password = $edgDBPass[$dbID];
169169
170170 // Optional parameters
171 - if ( array_key_exists( $server_id, $edgDBFlags ) ) {
172 - $db_flags = $edgDBFlags[$server_id];
 171+ if ( array_key_exists( $dbID, $edgDBFlags ) ) {
 172+ $db_flags = $edgDBFlags[$dbID];
173173 } else {
174174 $db_flags = DBO_DEFAULT;
175175 }
176 - if ( array_key_exists( $server_id, $edgDBTablePrefix ) ) {
177 - $db_tableprefix = $edgDBTablePrefix[$server_id];
 176+ if ( array_key_exists( $dbID, $edgDBTablePrefix ) ) {
 177+ $db_tableprefix = $edgDBTablePrefix[$dbID];
178178 } else {
179179 $db_tableprefix = '';
180180 }

Status & tagging log