Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -1,7 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class FlaggedRevsHooks { |
5 | | - |
6 | 5 | /** |
7 | 6 | * Remove 'patrol' and 'autopatrol' rights. Reviewing revisions will patrol them as well. |
8 | 7 | */ |
— | — | @@ -227,7 +226,7 @@ |
228 | 227 | $dbw->delete( 'flaggedrevs_tracking', $where, __METHOD__ ); |
229 | 228 | } |
230 | 229 | # Add any new links |
231 | | - if ( count($insertions) ) { |
| 230 | + if( count($insertions) ) { |
232 | 231 | $dbw->insert( 'flaggedrevs_tracking', $insertions, __METHOD__, 'IGNORE' ); |
233 | 232 | } |
234 | 233 | wfProfileOut( __METHOD__ ); |
— | — | @@ -254,7 +253,6 @@ |
255 | 254 | } |
256 | 255 | $arr[$row->ftr_namespace][$row->ftr_title] = 1; |
257 | 256 | } |
258 | | - $dbr->freeResult( $res ); |
259 | 257 | return $arr; |
260 | 258 | } |
261 | 259 | |
— | — | @@ -604,12 +602,12 @@ |
605 | 603 | global $wgFlaggedRevsVisible, $wgFlaggedRevsTalkVisible, $wgTitle; |
606 | 604 | # Assume $action may still not be set, in which case, treat it as 'view'... |
607 | 605 | # 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 ) |
609 | 607 | return true; |
610 | 608 | # Admin may set this to false, rather than array()... |
611 | 609 | $groups = $user->getGroups(); |
612 | 610 | $groups[] = '*'; |
613 | | - if( empty($wgFlaggedRevsVisible) || !array_intersect($groups,$wgFlaggedRevsVisible) ) |
| 611 | + if( !array_intersect($groups,$wgFlaggedRevsVisible) ) |
614 | 612 | return true; |
615 | 613 | # Is this a talk page? |
616 | 614 | if( $wgFlaggedRevsTalkVisible && $title->isTalkPage() ) { |
— | — | @@ -1084,7 +1082,7 @@ |
1085 | 1083 | |
1086 | 1084 | public static function setActionTabs( $skin, &$contentActions ) { |
1087 | 1085 | $fa = FlaggedArticle::getGlobalInstance(); |
1088 | | - if ( $fa ) { |
| 1086 | + if( $fa ) { |
1089 | 1087 | $fa->setActionTabs( $skin, $contentActions ); |
1090 | 1088 | } |
1091 | 1089 | return true; |
— | — | @@ -1267,7 +1265,7 @@ |
1268 | 1266 | } |
1269 | 1267 | $watchlist = SpecialPage::getTitleFor( 'Watchlist' ); |
1270 | 1268 | $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)) ) { |
1272 | 1270 | $dbr = wfGetDB( DB_SLAVE ); |
1273 | 1271 | $unreviewed = $dbr->estimateRowCount( 'flaggedpages', '*', array('fp_reviewed' => 0), __METHOD__ ); |
1274 | 1272 | if( $unreviewed >= $wgFlaggedRevsBacklog ) { |
— | — | @@ -1297,19 +1295,19 @@ |
1298 | 1296 | abstract class FlaggedRevsApiHooks extends ApiQueryBase { |
1299 | 1297 | |
1300 | 1298 | public static function addApiRevisionParams ( &$module, &$params ) { |
1301 | | - if (!$module instanceof ApiQueryRevisions) |
| 1299 | + if(!$module instanceof ApiQueryRevisions) |
1302 | 1300 | return true; |
1303 | 1301 | $params['prop'][ApiBase::PARAM_TYPE][] = 'flagged'; |
1304 | 1302 | return true; |
1305 | 1303 | } |
1306 | 1304 | |
1307 | 1305 | public static function addApiRevisionData( &$module ) { |
1308 | | - if (!$module instanceof ApiQueryRevisions) |
| 1306 | + if(!$module instanceof ApiQueryRevisions) |
1309 | 1307 | return true; |
1310 | 1308 | $params = $module->extractRequestParams( false ); |
1311 | | - if ( empty( $params['prop'] ) || !in_array( 'flagged', $params['prop'] ) ) |
| 1309 | + if( empty( $params['prop'] ) || !in_array( 'flagged', $params['prop'] ) ) |
1312 | 1310 | return true; |
1313 | | - if ( !in_array( 'ids', $params['prop'] ) ) |
| 1311 | + if( !in_array( 'ids', $params['prop'] ) ) |
1314 | 1312 | $module->dieUsage( 'if rvprop=flagged is set, you must also set rvprop=ids', 'missingparam' ); |
1315 | 1313 | |
1316 | 1314 | // Get all requested pageids/revids in a mapping: |
— | — | @@ -1317,14 +1315,17 @@ |
1318 | 1316 | // we will need this later to add data to the result array |
1319 | 1317 | $result = $module->getResult(); |
1320 | 1318 | $data = $result->getData(); |
1321 | | - if ( !isset( $data['query'] ) || !isset( $data['query']['pages'] ) ) |
| 1319 | + if( !isset( $data['query'] ) || !isset( $data['query']['pages'] ) ) |
1322 | 1320 | 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 ) ) |
1327 | 1325 | $pageids[$pageid][$rev['revid']] = $index; |
1328 | | - if ( empty( $pageids ) ) |
| 1326 | + } |
| 1327 | + } |
| 1328 | + } |
| 1329 | + if( empty( $pageids ) ) |
1329 | 1330 | return true; |
1330 | 1331 | |
1331 | 1332 | //Construct SQL Query |
— | — | @@ -1344,10 +1345,10 @@ |
1345 | 1346 | |
1346 | 1347 | //Construct WHERE-clause to avoid multiplying the number of scanned rows |
1347 | 1348 | //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 | + } |
1352 | 1353 | $module->addWhere( $db->makeList( $where, LIST_OR ) ); |
1353 | 1354 | $module->addOption( 'USE INDEX', array( 'flaggedrevs' => 'PRIMARY' ) ); |
1354 | 1355 | |
— | — | @@ -1363,7 +1364,7 @@ |
1364 | 1365 | 'level_text' => FlaggedRevs::getQualityLevelText( $row->fr_quality ), |
1365 | 1366 | 'tags' => FlaggedRevision::expandRevisionTags( $row->fr_tags ) |
1366 | 1367 | ); |
1367 | | - if ( $row->fr_comment ) |
| 1368 | + if( $row->fr_comment ) |
1368 | 1369 | $data['comment'] = $row->fr_comment; |
1369 | 1370 | $result->addValue( |
1370 | 1371 | array( 'query', 'pages', $row->fr_page_id, 'revisions', $index ), |