r52961 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52960‎ | r52961 | r52962 >
Date:02:29, 9 July 2009
Author:aaron
Status:ok
Tags:
Comment:
Move some initializing to getUserParams()
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -1181,21 +1181,28 @@
11821182 */
11831183 public static function getUserParams( $uid ) {
11841184 $dbw = wfGetDB( DB_MASTER );
1185 - $row = $dbw->selectRow( 'flaggedrevs_promote', 'frp_user_params',
 1185+ $row = $dbw->selectRow( 'flaggedrevs_promote',
 1186+ 'frp_user_params',
11861187 array( 'frp_user_id' => $uid ),
1187 - __METHOD__ );
 1188+ __METHOD__
 1189+ );
11881190 # Parse params
1189 - $params = array();
 1191+ $p = array(); // init
11901192 if( $row ) {
11911193 $flatPars = explode( "\n", trim($row->frp_user_params) );
11921194 foreach( $flatPars as $pair ) {
11931195 $m = explode( '=', trim($pair), 2 );
11941196 $key = $m[0];
11951197 $value = isset($m[1]) ? $m[1] : null;
1196 - $params[$key] = $value;
 1198+ $p[$key] = $value;
11971199 }
11981200 }
1199 - return $params;
 1201+ // Initialize fields as needed...
 1202+ if( !isset($p['uniqueContentPages']) ) $p['uniqueContentPages'] = '';
 1203+ if( !isset($p['totalContentEdits']) ) $p['totalContentEdits'] = 0;
 1204+ if( !isset($p['editComments']) ) $p['editComments'] = 0;
 1205+ if( !isset($p['revertedEdits']) ) $p['revertedEdits'] = 0;
 1206+ return $p;
12001207 }
12011208
12021209 /**

Status & tagging log