r34294 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34293‎ | r34294 | r34295 >
Date:03:01, 6 May 2008
Author:aaron
Status:old
Tags:
Comment:
* Fix autopromote, wasn't working
* Remove garbage ','
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -1696,6 +1696,7 @@
16971697 # Assume $action may still not be set, in which case, treat it as 'view'...
16981698 if( $action != 'read' )
16991699 return true;
 1700+ $p = self::getUserParams( $user );
17001701 # Admin may set this to false, rather than array()...
17011702 $groups = $user->getGroups();
17021703 $groups[] = '*';
@@ -1814,7 +1815,7 @@
18151816 # Don't let this get bloated for no reason
18161817 if( count($pages) < $wgFlaggedRevsAutopromote['uniqueContentPages'] && !in_array($article->getId(),$pages) ) {
18171818 $pages[] = $article->getId();
1818 - $p['uniqueContentPages'] = implode(',',$pages);
 1819+ $p['uniqueContentPages'] = preg_replace('/^,/','',implode(',',$pages)); // clear any garbage
18191820 }
18201821 $p['totalContentEdits'] += 1;
18211822 $changed = true;
@@ -2013,10 +2014,10 @@
20142015 $row = $dbw->selectRow( 'flaggedrevs_promote', 'frp_user_params',
20152016 array( 'frp_user_id' => $user->getId() ),
20162017 __METHOD__ );
2017 -
 2018+ # Parse params
20182019 $params = array();
20192020 if( $row ) {
2020 - $flatPars = explode( '\n', trim($row->frp_user_params) );
 2021+ $flatPars = explode( "\n", trim($row->frp_user_params) );
20212022 foreach( $flatPars as $pair ) {
20222023 $m = explode( '=', trim($pair), 2 );
20232024 $key = $m[0];
@@ -2037,13 +2038,11 @@
20382039 foreach( $params as $key => $value ) {
20392040 $flatParams .= "{$key}={$value}\n";
20402041 }
2041 - $flatParams = trim($flatParams);
2042 -
20432042 $dbw = wfGetDB( DB_MASTER );
20442043 $row = $dbw->replace( 'flaggedrevs_promote',
20452044 array( 'frp_user_id' ),
20462045 array( 'frp_user_id' => $user->getId(),
2047 - 'frp_user_params' => $flatParams ),
 2046+ 'frp_user_params' => trim($flatParams) ),
20482047 __METHOD__ );
20492048
20502049 return ( $dbw->affectedRows() > 0 );

Status & tagging log