r56798 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56797‎ | r56798 | r56799 >
Date:03:32, 23 September 2009
Author:aaron
Status:ok
Tags:
Comment:
* Fixed possible fatal on cross-wiki Editor demotions
* Dealt with re-promotion issue for cross-wiki demotions
* Doc fixes
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -1131,9 +1131,11 @@
11321132 /**
11331133 * Get params for a user
11341134 * @param int $uid
 1135+ * @param string $DBName, optional wiki name
 1136+ * @returns Array $params
11351137 */
1136 - public static function getUserParams( $uid ) {
1137 - $dbw = wfGetDB( DB_MASTER );
 1138+ public static function getUserParams( $uid, $DBName = false ) {
 1139+ $dbw = wfGetDB( DB_MASTER, array(), $DBName );
11381140 $row = $dbw->selectRow( 'flaggedrevs_promote',
11391141 'frp_user_params',
11401142 array( 'frp_user_id' => $uid ),
@@ -1161,14 +1163,16 @@
11621164 /**
11631165 * Save params for a user
11641166 * @param int $uid
 1167+ * @param string $DBName, optional wiki name
11651168 * @param Array $params
 1169+ * @returns bool success
11661170 */
1167 - public static function saveUserParams( $uid, $params ) {
 1171+ public static function saveUserParams( $uid, $params, $DBName = false ) {
11681172 $flatParams = '';
11691173 foreach( $params as $key => $value ) {
11701174 $flatParams .= "{$key}={$value}\n";
11711175 }
1172 - $dbw = wfGetDB( DB_MASTER );
 1176+ $dbw = wfGetDB( DB_MASTER, array(), $DBName );
11731177 $row = $dbw->replace( 'flaggedrevs_promote',
11741178 array( 'frp_user_id' ),
11751179 array( 'frp_user_id' => $uid, 'frp_user_params' => trim($flatParams) ),
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1308,9 +1308,17 @@
13091309 */
13101310 public static function recordDemote( $u, $addgroup, $removegroup ) {
13111311 if( $removegroup && in_array('editor',$removegroup) ) {
1312 - $params = FlaggedRevs::getUserParams( $u->getId() );
1313 - $params['demoted'] = 1;
1314 - FlaggedRevs::saveUserParams( $u->getId(), $params );
 1312+ // Cross-wiki rights change
 1313+ if( $u instanceof UserRightsProxy ) {
 1314+ $params = FlaggedRevs::getUserParams( $u->getId(), $u->getDBName() );
 1315+ $params['demoted'] = 1;
 1316+ FlaggedRevs::saveUserParams( $u->getId(), $params, $dbname );
 1317+ // On-wiki rights change
 1318+ } else {
 1319+ $params = FlaggedRevs::getUserParams( $u->getId() );
 1320+ $params['demoted'] = 1;
 1321+ FlaggedRevs::saveUserParams( $u->getId(), $params );
 1322+ }
13151323 }
13161324 return true;
13171325 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r56800Fixed bogus var from r56798aaron03:38, 23 September 2009
r56801Missing commit for r56798aaron03:42, 23 September 2009

Status & tagging log