r92813 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92812‎ | r92813 | r92814 >
Date:22:19, 21 July 2011
Author:robin
Status:ok
Tags:
Comment:
Fixes for r92538 & r92528:
* use default null for $local
* use foreach for database result
Modified paths:
  • /trunk/phase3/includes/interwiki/Interwiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/interwiki/Interwiki.php
@@ -201,7 +201,7 @@
202202 /**
203203 * Fetch all interwiki prefixes from interwiki cache
204204 *
205 - * @param $local If set, limits output to local/non-local interwikis
 205+ * @param $local If not null, limits output to local/non-local interwikis
206206 * @return Array List of prefixes
207207 * @since 1.19
208208 */
@@ -245,7 +245,7 @@
246246
247247 list( $iw_local, $iw_url ) = explode( ' ', $row );
248248
249 - if ( isset( $local ) && $local != $iw_local ) {
 249+ if ( $local !== null && $local != $iw_local ) {
250250 continue;
251251 }
252252
@@ -265,7 +265,7 @@
266266 /**
267267 * Fetch all interwiki prefixes from DB
268268 *
269 - * @param $local If set, limits output to local/non-local interwikis
 269+ * @param $local If not null, limits output to local/non-local interwikis
270270 * @return Array List of prefixes
271271 * @since 1.19
272272 */
@@ -274,7 +274,7 @@
275275
276276 $where = array();
277277
278 - if ( isset( $local ) ) {
 278+ if ( $local !== null ) {
279279 if ( $local == 1 ) {
280280 $where['iw_local'] = 1;
281281 } elseif ( $local == 0 ) {
@@ -282,10 +282,15 @@
283283 }
284284 }
285285
286 - return $db->select( 'interwiki',
 286+ $res = $db->select( 'interwiki',
287287 array( 'iw_prefix', 'iw_url', 'iw_api', 'iw_wikiid', 'iw_local', 'iw_trans' ),
288288 $where, __METHOD__, array( 'ORDER BY' => 'iw_prefix' )
289289 );
 290+ $retval = array();
 291+ foreach ( $res as $row ) {
 292+ $retval[] = (array)$row;
 293+ }
 294+ return $retval;
290295 }
291296
292297 /**
@@ -295,7 +300,7 @@
296301 * @return Array List of prefixes
297302 * @since 1.19
298303 */
299 - public static function getAllPrefixes( $local ) {
 304+ public static function getAllPrefixes( $local = null ) {
300305 global $wgInterwikiCache;
301306
302307 if ( $wgInterwikiCache ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92528(bug 19838) API does not use interwiki cache....robin12:30, 19 July 2011
r92538Follow-up r92528:...robin15:52, 19 July 2011

Status & tagging log