r44040 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44039‎ | r44040 | r44041 >
Date:17:31, 29 November 2008
Author:aaron
Status:deferred
Tags:
Comment:
Minor code cleanup
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1,7 +1,6 @@
22 <?php
33
44 class FlaggedRevsHooks {
5 -
65 /**
76 * Remove 'patrol' and 'autopatrol' rights. Reviewing revisions will patrol them as well.
87 */
@@ -227,7 +226,7 @@
228227 $dbw->delete( 'flaggedrevs_tracking', $where, __METHOD__ );
229228 }
230229 # Add any new links
231 - if ( count($insertions) ) {
 230+ if( count($insertions) ) {
232231 $dbw->insert( 'flaggedrevs_tracking', $insertions, __METHOD__, 'IGNORE' );
233232 }
234233 wfProfileOut( __METHOD__ );
@@ -254,7 +253,6 @@
255254 }
256255 $arr[$row->ftr_namespace][$row->ftr_title] = 1;
257256 }
258 - $dbr->freeResult( $res );
259257 return $arr;
260258 }
261259
@@ -604,12 +602,12 @@
605603 global $wgFlaggedRevsVisible, $wgFlaggedRevsTalkVisible, $wgTitle;
606604 # Assume $action may still not be set, in which case, treat it as 'view'...
607605 # Return out if $result set to false by some other hooked call.
608 - if( !$wgFlaggedRevsVisible || $action != 'read' || $result===false )
 606+ if( empty($wgFlaggedRevsVisible) || $action !== 'read' || $result===false )
609607 return true;
610608 # Admin may set this to false, rather than array()...
611609 $groups = $user->getGroups();
612610 $groups[] = '*';
613 - if( empty($wgFlaggedRevsVisible) || !array_intersect($groups,$wgFlaggedRevsVisible) )
 611+ if( !array_intersect($groups,$wgFlaggedRevsVisible) )
614612 return true;
615613 # Is this a talk page?
616614 if( $wgFlaggedRevsTalkVisible && $title->isTalkPage() ) {
@@ -1084,7 +1082,7 @@
10851083
10861084 public static function setActionTabs( $skin, &$contentActions ) {
10871085 $fa = FlaggedArticle::getGlobalInstance();
1088 - if ( $fa ) {
 1086+ if( $fa ) {
10891087 $fa->setActionTabs( $skin, $contentActions );
10901088 }
10911089 return true;
@@ -1267,7 +1265,7 @@
12681266 }
12691267 $watchlist = SpecialPage::getTitleFor( 'Watchlist' );
12701268 $recentchanges = SpecialPage::getTitleFor( 'Recentchanges' );
1271 - if ( $wgUser->isAllowed('review') && ($wgTitle->equals($watchlist) || $wgTitle->equals($recentchanges)) ) {
 1269+ if( $wgUser->isAllowed('review') && ($wgTitle->equals($watchlist) || $wgTitle->equals($recentchanges)) ) {
12721270 $dbr = wfGetDB( DB_SLAVE );
12731271 $unreviewed = $dbr->estimateRowCount( 'flaggedpages', '*', array('fp_reviewed' => 0), __METHOD__ );
12741272 if( $unreviewed >= $wgFlaggedRevsBacklog ) {
@@ -1297,19 +1295,19 @@
12981296 abstract class FlaggedRevsApiHooks extends ApiQueryBase {
12991297
13001298 public static function addApiRevisionParams ( &$module, &$params ) {
1301 - if (!$module instanceof ApiQueryRevisions)
 1299+ if(!$module instanceof ApiQueryRevisions)
13021300 return true;
13031301 $params['prop'][ApiBase::PARAM_TYPE][] = 'flagged';
13041302 return true;
13051303 }
13061304
13071305 public static function addApiRevisionData( &$module ) {
1308 - if (!$module instanceof ApiQueryRevisions)
 1306+ if(!$module instanceof ApiQueryRevisions)
13091307 return true;
13101308 $params = $module->extractRequestParams( false );
1311 - if ( empty( $params['prop'] ) || !in_array( 'flagged', $params['prop'] ) )
 1309+ if( empty( $params['prop'] ) || !in_array( 'flagged', $params['prop'] ) )
13121310 return true;
1313 - if ( !in_array( 'ids', $params['prop'] ) )
 1311+ if( !in_array( 'ids', $params['prop'] ) )
13141312 $module->dieUsage( 'if rvprop=flagged is set, you must also set rvprop=ids', 'missingparam' );
13151313
13161314 // Get all requested pageids/revids in a mapping:
@@ -1317,14 +1315,17 @@
13181316 // we will need this later to add data to the result array
13191317 $result = $module->getResult();
13201318 $data = $result->getData();
1321 - if ( !isset( $data['query'] ) || !isset( $data['query']['pages'] ) )
 1319+ if( !isset( $data['query'] ) || !isset( $data['query']['pages'] ) )
13221320 return true;
1323 - foreach ( $data['query']['pages'] as $pageid => $page )
1324 - if ( array_key_exists( 'revisions', (array)$page ) )
1325 - foreach ( $page['revisions'] as $index => $rev )
1326 - if ( array_key_exists( 'revid', (array)$rev ) )
 1321+ foreach( $data['query']['pages'] as $pageid => $page ) {
 1322+ if( array_key_exists( 'revisions', (array)$page ) ) {
 1323+ foreach ( $page['revisions'] as $index => $rev ) {
 1324+ if( array_key_exists( 'revid', (array)$rev ) )
13271325 $pageids[$pageid][$rev['revid']] = $index;
1328 - if ( empty( $pageids ) )
 1326+ }
 1327+ }
 1328+ }
 1329+ if( empty( $pageids ) )
13291330 return true;
13301331
13311332 //Construct SQL Query
@@ -1344,10 +1345,10 @@
13451346
13461347 //Construct WHERE-clause to avoid multiplying the number of scanned rows
13471348 //as flaggedrevs table has composite primary key (fr_page_id,fr_rev_id)
1348 - foreach ( $pageids as $pageid => $revids )
1349 - $where[] = $db->makeList( array(
1350 - 'fr_page_id' => $pageid,
1351 - 'fr_rev_id' => array_keys( $revids ) ), LIST_AND );
 1349+ foreach( $pageids as $pageid => $revids ) {
 1350+ $where[] = $db->makeList( array( 'fr_page_id' => $pageid,
 1351+ 'fr_rev_id' => array_keys( $revids ) ), LIST_AND );
 1352+ }
13521353 $module->addWhere( $db->makeList( $where, LIST_OR ) );
13531354 $module->addOption( 'USE INDEX', array( 'flaggedrevs' => 'PRIMARY' ) );
13541355
@@ -1363,7 +1364,7 @@
13641365 'level_text' => FlaggedRevs::getQualityLevelText( $row->fr_quality ),
13651366 'tags' => FlaggedRevision::expandRevisionTags( $row->fr_tags )
13661367 );
1367 - if ( $row->fr_comment )
 1368+ if( $row->fr_comment )
13681369 $data['comment'] = $row->fr_comment;
13691370 $result->addValue(
13701371 array( 'query', 'pages', $row->fr_page_id, 'revisions', $index ),

Status & tagging log