r71290 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71289‎ | r71290 | r71291 >
Date:11:53, 19 August 2010
Author:reedy
Status:deferred
Tags:
Comment:
Remove unused variables (mainly globals)

Add some braces

Change $dbw to $db in one case
Modified paths:
  • /trunk/extensions/AssertEdit/AssertEdit.php (modified) (history)
  • /trunk/extensions/CentralAuth/SpecialGlobalUsers.php (modified) (history)
  • /trunk/extensions/CentralAuth/WikiSet.php (modified) (history)
  • /trunk/extensions/CheckUser/cu_log_import.inc (modified) (history)
  • /trunk/extensions/CheckUser/importLog.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/api/ApiQueryFlagged.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/forms/RevisionReviewForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/flagToSemiProtect.inc (modified) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/reviewAllPages.inc (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ProblemChanges_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ReviewedPages_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/ReviewedVersions_body.php (modified) (history)
  • /trunk/extensions/Gadgets/SpecialGadgets.php (modified) (history)
  • /trunk/extensions/GlobalBlocking/ApiQueryGlobalBlocks.php (modified) (history)
  • /trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php (modified) (history)
  • /trunk/extensions/GlobalBlocking/SpecialGlobalBlockList.php (modified) (history)
  • /trunk/extensions/GlobalBlocking/SpecialGlobalBlockStatus.php (modified) (history)
  • /trunk/extensions/GlobalBlocking/SpecialRemoveGlobalBlock.php (modified) (history)
  • /trunk/extensions/OAI/OAIRepo.php (modified) (history)
  • /trunk/extensions/OggHandler/OggHandler_body.php (modified) (history)
  • /trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php (modified) (history)
  • /trunk/extensions/Oversight/HideRevision_body.php (modified) (history)
  • /trunk/extensions/Renameuser/Renameuser_body.php (modified) (history)
  • /trunk/extensions/SecurePoll/includes/ballots/Ballot.php (modified) (history)
  • /trunk/extensions/SecurePoll/includes/main/Base.php (modified) (history)
  • /trunk/extensions/SecurePoll/includes/pages/MessageDumpPage.php (modified) (history)
  • /trunk/extensions/SecurePoll/includes/pages/VotePage.php (modified) (history)
  • /trunk/extensions/SecurePoll/includes/user/Auth.php (modified) (history)
  • /trunk/extensions/SiteMatrix/SiteMatrix_body.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefStats/SpecialPrefStats.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.classes.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php
@@ -157,7 +157,7 @@
158158 }
159159
160160 function form( $error ) {
161 - global $wgUser, $wgRequest,$wgScript,$wgOut;
 161+ global $wgUser, $wgScript, $wgOut;
162162
163163 $form = '';
164164
Index: trunk/extensions/GlobalBlocking/ApiQueryGlobalBlocks.php
@@ -48,34 +48,40 @@
4949 $fld_range = isset($prop['range']);
5050
5151 $result = $this->getResult();
52 - $pageSet = $this->getPageSet();
53 - $titles = $pageSet->getTitles();
5452 $data = array();
5553
5654 $this->addTables('globalblocks');
57 - if($fld_id)
 55+ if ($fld_id) {
5856 $this->addFields('gb_id');
59 - if($fld_address)
 57+ }
 58+ if ($fld_address) {
6059 $this->addFields(array('gb_address', 'gb_anon_only'));
61 - if($fld_by)
 60+ }
 61+ if ($fld_by) {
6262 $this->addFields(array('gb_by', 'gb_by_wiki'));
63 - if($fld_timestamp)
 63+ }
 64+ if ($fld_timestamp) {
6465 $this->addFields('gb_timestamp');
65 - if($fld_expiry)
 66+ }
 67+ if ($fld_expiry) {
6668 $this->addFields('gb_expiry');
67 - if($fld_reason)
 69+ }
 70+ if ($fld_reason) {
6871 $this->addFields('gb_reason');
69 - if($fld_range)
 72+ }
 73+ if ($fld_range) {
7074 $this->addFields(array('gb_range_start', 'gb_range_end'));
 75+ }
7176
7277 $this->addOption('LIMIT', $params['limit'] + 1);
7378 $this->addWhereRange('gb_timestamp', $params['dir'], $params['start'], $params['end']);
74 - if(isset($params['ids']))
 79+ if (isset($params['ids'])) {
7580 $this->addWhereFld('gb_id', $params['ids']);
76 - if(isset($params['addresses']))
 81+ }
 82+ if (isset($params['addresses'])) {
7783 $this->addWhereFld('gb_address', $params['addresses']);
78 - if(isset($params['ip']))
79 - {
 84+ }
 85+ if(isset($params['ip'])) {
8086 list($ip, $range) = IP::parseCIDR($params['ip']);
8187 if($ip && $range)
8288 {
Index: trunk/extensions/GlobalBlocking/SpecialGlobalBlockStatus.php
@@ -136,7 +136,7 @@
137137 }
138138
139139 function form( $error ) {
140 - global $wgRequest,$wgUser,$wgOut;
 140+ global $wgUser, $wgOut;
141141
142142 $wgOut->addWikiMsg( 'globalblocking-whitelist-intro' );
143143
Index: trunk/extensions/GlobalBlocking/SpecialGlobalBlockList.php
@@ -9,7 +9,7 @@
1010 }
1111
1212 function execute( $par ) {
13 - global $wgUser,$wgOut,$wgRequest;
 13+ global $wgOut, $wgRequest;
1414
1515 $this->setHeaders();
1616 $ip = isset( $par ) ? $par : $wgRequest->getText( 'ip' );
@@ -25,7 +25,7 @@
2626 }
2727
2828 function showList( ) {
29 - global $wgOut,$wgScript,$wgUser;
 29+ global $wgOut, $wgScript;
3030 $errors = array();
3131
3232 // Validate search IP
@@ -106,7 +106,6 @@
107107 }
108108
109109 function loadParameters( $ip ) {
110 - global $wgUser;
111110 $this->mSearchIP = Block::normaliseRange( trim( $ip ) );
112111 }
113112 }
Index: trunk/extensions/GlobalBlocking/SpecialRemoveGlobalBlock.php
@@ -103,7 +103,7 @@
104104 }
105105
106106 function form( ) {
107 - global $wgScript,$wgRequest,$wgUser,$wgOut;
 107+ global $wgScript, $wgUser, $wgOut;
108108
109109 $form = '';
110110
Index: trunk/extensions/OggHandler/OggHandler_body.php
@@ -426,7 +426,7 @@
427427 }
428428
429429 function setHeaders( $out ) {
430 - global $wgOggScriptVersion, $wgCortadoJarFile, $wgServer, $wgUser, $wgScriptPath;
 430+ global $wgOggScriptVersion, $wgCortadoJarFile, $wgServer;
431431
432432 if ( $out->hasHeadItem( 'OggHandlerScript' ) && $out->hasHeadItem( 'OggHandlerInlineScript' ) &&
433433 $out->hasHeadItem( 'OggHandlerInlineCSS' ) ) {
Index: trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php
@@ -142,8 +142,6 @@
143143 * @access private
144144 */
145145 function _stripMarkup( $text ) {
146 - global $wgContLang;
147 -
148146 $text = substr( $text, 0, 4096 ); // don't bother with long text...
149147
150148 $text = str_replace( "'''", "", $text );
Index: trunk/extensions/Oversight/HideRevision_body.php
@@ -58,7 +58,7 @@
5959 * If no revisions are specified, prompt for a revision id
6060 */
6161 function showEmpty() {
62 - global $wgOut, $wgUser;
 62+ global $wgOut;
6363 $special = SpecialPage::getTitleFor( 'HideRevision' );
6464
6565 $wgOut->addHTML(
@@ -131,8 +131,6 @@
132132 require_once( "$IP/includes/ChangesList.php" );
133133 $changes = ChangesList::newFromUser( $wgUser );
134134
135 - $skin = $wgUser->getSkin();
136 -
137135 $out = $changes->beginRecentChangesList();
138136 while( $row = $resultSet->fetchObject() ) {
139137 $rc = RecentChange::newFromCurRow( $row );
@@ -244,8 +242,6 @@
245243 * @return message key string for success or failure message
246244 */
247245 function hideRevision( $dbw, $id ) {
248 - global $wgUser;
249 -
250246 $dbw->begin();
251247
252248 $rev = Revision::newFromId( $id );
Index: trunk/extensions/UsabilityInitiative/PrefSwitch/PrefSwitch.classes.php
@@ -25,7 +25,7 @@
2626 * @return string HTML
2727 */
2828 public static function render( $name, $questions, $loadFromDB = false ) {
29 - global $wgUser, $wgOut;
 29+ global $wgUser;
3030 // Load existing data from the database - allowing the user to change their answers
3131 $loaded = array();
3232 if ( $loadFromDB ) {
Index: trunk/extensions/UsabilityInitiative/OptIn/SpecialOptIn.php
@@ -164,7 +164,7 @@
165165 /* Private Functions */
166166
167167 private function showForm( $opt ) {
168 - global $wgUser, $wgOut, $wgOptInSurvey, $wgOptInFeedBackSurvey;
 168+ global $wgOut, $wgOptInSurvey, $wgOptInFeedBackSurvey;
169169
170170 if ( $opt == 'out' ) {
171171 $wgOut->addWikiMsg( 'optin-survey-intro' );
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -13,7 +13,6 @@
1414 private static $doOutput = false;
1515 private static $messages = array();
1616 private static $variables = array();
17 - private static $literalVariables = array();
1817 private static $styles = array();
1918 private static $styleFiles = array(
2019 'base_sets' => array(
Index: trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.php
@@ -10,10 +10,8 @@
1111
1212 private static $minimum_date = '20091009'; // YYYYMMDD (+1 for today)
1313
14 - private static $userTypes = array( "basic" => 0, "intermediate" => 1, "expert" => 2 );
1514 private $user_defs = array();
16 -
17 -
 15+
1816 function __construct() {
1917 parent::__construct( 'ClickTracking' , 'clicktrack' );
2018 wfLoadExtensionMessages( 'ClickTracking' );
Index: trunk/extensions/UsabilityInitiative/PrefStats/SpecialPrefStats.php
@@ -13,7 +13,7 @@
1414 }
1515
1616 function execute( $par ) {
17 - global $wgRequest, $wgOut, $wgUser, $wgPrefStatsTrackPrefs;
 17+ global $wgOut, $wgUser, $wgPrefStatsTrackPrefs;
1818 $this->setHeaders();
1919
2020 // Check permissions
Index: trunk/extensions/CentralAuth/WikiSet.php
@@ -9,7 +9,6 @@
1010 private $mName; // Display name of the group
1111 private $mType; // Opt-in based or opt-out based
1212 private $mWikis; // List of wikis
13 - private $mVersion = self::VERSION; // Caching purposes
1413
1514 static $mCacheVars = array(
1615 'mId',
Index: trunk/extensions/CentralAuth/SpecialGlobalUsers.php
@@ -97,7 +97,7 @@
9898 * @return string HTML li element with username and info about this user
9999 */
100100 function formatRow( $row ) {
101 - global $wgLang, $wgContLang;
 101+ global $wgLang;
102102 $user = htmlspecialchars( $row->gu_name );
103103 $info = array();
104104 if ( $row->gu_locked ) {
Index: trunk/extensions/Gadgets/SpecialGadgets.php
@@ -132,7 +132,7 @@
133133 * @param $gadget String Name of gadget to export
134134 */
135135 public function showExportForm( $gadget ) {
136 - global $wgOut, $wgRequest, $wgUser, $wgScript;
 136+ global $wgOut, $wgScript;
137137
138138 $gadgets = wfLoadGadgets();
139139 if ( !isset( $gadgets[$gadget] ) ) {
Index: trunk/extensions/SiteMatrix/SiteMatrix_body.php
@@ -16,7 +16,7 @@
1717
1818 public function __construct(){
1919 global $wgSiteMatrixFile, $wgSiteMatrixSites;
20 - global $wgLocalDatabases, $IP, $wgConf;
 20+ global $wgLocalDatabases, $wgConf;
2121
2222 $wgConf->loadFullData();
2323
@@ -347,7 +347,6 @@
348348
349349 public function execute() {
350350 global $wgLanguageNames;
351 - $params = $this->extractRequestParams();
352351 $result = $this->getResult();
353352 $matrix = new SiteMatrix();
354353
Index: trunk/extensions/FlaggedRevs/forms/RevisionReviewForm.php
@@ -324,7 +324,6 @@
325325 * @returns true on success, array of errors on failure
326326 */
327327 private function approveRevision( Revision $rev ) {
328 - global $wgMemc, $wgParser;
329328 wfProfileIn( __METHOD__ );
330329 # Revision rating flags
331330 $flags = $this->dims;
Index: trunk/extensions/FlaggedRevs/specialpages/ReviewedVersions_body.php
@@ -31,7 +31,7 @@
3232 }
3333
3434 protected function showStableList() {
35 - global $wgOut, $wgUser, $wgLang;
 35+ global $wgOut, $wgLang;
3636 # Must be a content page
3737 if ( !FlaggedRevs::inReviewNamespace( $this->page ) ) {
3838 $wgOut->addWikiMsg( 'reviewedversions-none', $this->page->getPrefixedText() );
@@ -52,7 +52,7 @@
5353 }
5454
5555 public function formatRow( $row ) {
56 - global $wgLang, $wgUser;
 56+ global $wgLang;
5757 $rdatim = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
5858 $fdatim = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->fr_timestamp ), true );
5959 $fdate = $wgLang->date( wfTimestamp( TS_MW, $row->fr_timestamp ), true );
Index: trunk/extensions/FlaggedRevs/specialpages/ProblemChanges_body.php
@@ -12,7 +12,7 @@
1313 }
1414
1515 public function execute( $par ) {
16 - global $wgRequest, $wgUser, $wgOut;
 16+ global $wgRequest, $wgUser;
1717 $this->setHeaders();
1818 $this->skin = $wgUser->getSkin();
1919 $this->level = $wgRequest->getInt( 'level', - 1 );
@@ -40,7 +40,7 @@
4141 }
4242
4343 public function showList( $par ) {
44 - global $wgOut, $wgScript, $wgUser;
 44+ global $wgOut, $wgScript;
4545 $limit = $this->parseParams( $par );
4646 $pager = new ProblemChangesPager( $this, $this->level, $this->category, $this->tag );
4747 // Apply limit if transcluded
@@ -92,7 +92,6 @@
9393 }
9494
9595 protected function parseParams( $par ) {
96 - global $wgLang;
9796 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
9897 $limit = false;
9998 foreach ( $bits as $bit ) {
@@ -298,7 +297,7 @@
299298 }
300299
301300 function getQueryInfo() {
302 - global $wgUser, $wgOldChangeTagsIndex;
 301+ global $wgOldChangeTagsIndex;
303302 $conds = $this->mConds;
304303 $tables = array( 'revision', 'change_tag', 'page' );
305304 $fields = array( 'page_namespace' , 'page_title', 'page_latest' );
Index: trunk/extensions/FlaggedRevs/specialpages/ReviewedPages_body.php
@@ -63,7 +63,7 @@
6464 }
6565
6666 protected function showPageList() {
67 - global $wgOut, $wgUser, $wgLang;
 67+ global $wgOut, $wgLang;
6868
6969 $pager = new ReviewedPagesPager( $this, array(), $this->type,
7070 $this->namespace, $this->hideRedirs );
@@ -82,7 +82,7 @@
8383 }
8484
8585 public function formatRow( $row ) {
86 - global $wgLang, $wgUser;
 86+ global $wgLang;
8787
8888 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
8989 $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() );
Index: trunk/extensions/FlaggedRevs/api/ApiQueryFlagged.php
@@ -29,11 +29,11 @@
3030 class ApiQueryFlagged extends ApiQueryBase {
3131
3232 public function execute() {
33 - $params = $this->extractRequestParams();
3433 $pageSet = $this->getPageSet();
3534 $pageids = array_keys( $pageSet->getGoodTitles() );
36 - if ( !$pageids )
 35+ if ( !$pageids ) {
3736 return true;
 37+ }
3838
3939 // Construct SQL Query
4040 $this->addTables( 'flaggedpages' );
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -857,7 +857,7 @@
858858 * Adds stable version tags to page when editing
859859 */
860860 public function addToEditView( EditPage $editPage ) {
861 - global $wgRequest, $wgOut, $wgLang, $wgUser;
 861+ global $wgOut, $wgUser;
862862 $this->load();
863863 # Must be reviewable. UI may be limited to unobtrusive patrolling system.
864864 if ( !$this->article->isReviewable() ) {
@@ -1067,7 +1067,7 @@
10681068 * Add link to stable version setting to protection form
10691069 */
10701070 public function addVisibilityLink( &$data ) {
1071 - global $wgUser, $wgRequest, $wgOut;
 1071+ global $wgRequest, $wgOut;
10721072 $this->load();
10731073 if ( FlaggedRevs::useProtectionLevels() ) {
10741074 return true; // simple custom levels set for action=protect
Index: trunk/extensions/FlaggedRevs/maintenance/flagToSemiProtect.inc
@@ -1,7 +1,7 @@
22 <?php
33
44 function flag_to_semi_protect( $db, $reason ) {
5 - global $wgUser, $wgFlaggedRevsNamespaces, $wgFlaggedRevsProtection;
 5+ global $wgFlaggedRevsNamespaces, $wgFlaggedRevsProtection;
66 echo "Semi-protecting all flag-protected pages...\n";
77 if ( !$wgFlaggedRevsProtection ) {
88 echo "\$wgFlaggedRevsProtection not enabled!\n";
Index: trunk/extensions/FlaggedRevs/maintenance/reviewAllPages.inc
@@ -41,7 +41,7 @@
4242 $db->begin();
4343 FlaggedRevs::autoReviewEdit( $article, $user, $rev, $flags, true );
4444 FlaggedRevs::HTMLCacheUpdates( $article->getTitle() );
45 - $dbw->commit();
 45+ $db->commit();
4646 $changed++;
4747 }
4848 $count++;
Index: trunk/extensions/OAI/OAIRepo.php
@@ -128,7 +128,6 @@
129129 }
130130
131131 function oaiUpdateUndelete( $title, $isnewid ) {
132 - global $wgDBname;
133132 $article = new Article($title);
134133 $id = $article->getID();
135134 oaiUpdatePage( $id, 'modify' );
Index: trunk/extensions/AssertEdit/AssertEdit.php
@@ -70,7 +70,7 @@
7171 }
7272
7373 function efAssertApiEditHook( $editPage, $textBox, &$result ) {
74 - global $wgOut, $wgRequest;
 74+ global $wgRequest;
7575
7676 $assertName = $wgRequest->getVal( 'assert' );
7777 $pass = true;
Index: trunk/extensions/SecurePoll/includes/main/Base.php
@@ -34,7 +34,7 @@
3535 * @param $paramString Mixed: parameter passed to the page or null
3636 */
3737 public function execute( $paramString ) {
38 - global $wgOut, $wgUser, $wgRequest, $wgScriptPath;
 38+ global $wgOut, $wgRequest, $wgScriptPath;
3939
4040 wfLoadExtensionMessages( 'SecurePoll' );
4141
Index: trunk/extensions/SecurePoll/includes/user/Auth.php
@@ -180,7 +180,7 @@
181181 * @return Status
182182 */
183183 function autoLogin( $election ) {
184 - global $wgUser, $wgServer, $wgLang;
 184+ global $wgUser;
185185 if ( $wgUser->isAnon() ) {
186186 return Status::newFatal( 'securepoll-not-logged-in' );
187187 }
Index: trunk/extensions/SecurePoll/includes/pages/MessageDumpPage.php
@@ -2,7 +2,7 @@
33
44 class SecurePoll_MessageDumpPage extends SecurePoll_Page {
55 function execute( $params ) {
6 - global $wgOut, $wgUser;
 6+ global $wgOut;
77
88 if ( !count( $params ) ) {
99 $wgOut->addWikiMsg( 'securepoll-too-few-params' );
Index: trunk/extensions/SecurePoll/includes/pages/VotePage.php
@@ -131,7 +131,6 @@
132132 * Shows an error message on failure.
133133 */
134134 function doSubmit() {
135 - global $wgOut;
136135 $ballot = $this->election->getBallot();
137136 $status = $ballot->submitForm();
138137 if ( !$status->isOK() ) {
Index: trunk/extensions/SecurePoll/includes/ballots/Ballot.php
@@ -118,7 +118,6 @@
119119 * @return string
120120 */
121121 function getForm( $prevStatus = false ) {
122 - global $wgParser, $wgTitle;
123122 $questions = $this->election->getQuestions();
124123 if ( $this->election->getProperty( 'shuffle-questions' ) ) {
125124 shuffle( $questions );
Index: trunk/extensions/CheckUser/importLog.php
@@ -12,7 +12,6 @@
1313
1414 $file = fopen( $log, 'r' );
1515 while ( false !== ( $line = fgets( $file ) ) ) {
16 - $found = false;
1716 $data = import_cu_log_line( $line );
1817 if ( $data ) {
1918 $matched++;
Index: trunk/extensions/CheckUser/cu_log_import.inc
@@ -43,7 +43,6 @@
4444 $unmatched = 0;
4545
4646 while ( false !== ( $line = fgets( $file ) ) ) {
47 - $found = false;
4847 $data = import_cu_log_line( $line );
4948 if( $data ) {
5049 if ( $data['wiki'] != wfWikiID() && $data['wiki'] != $wgDBname ) {
Index: trunk/extensions/Renameuser/Renameuser_body.php
@@ -26,7 +26,7 @@
2727 */
2828 public function execute( $par ) {
2929 global $wgOut, $wgUser, $wgRequest, $wgContLang, $wgLang;
30 - global $wgVersion, $wgMaxNameChars, $wgCapitalLinks;
 30+ global $wgCapitalLinks;
3131
3232 $this->setHeaders();
3333 $wgOut->addWikiMsg( 'renameuser-summary' );
@@ -402,7 +402,7 @@
403403 * Do the rename operation
404404 */
405405 function rename() {
406 - global $wgMemc, $wgDBname, $wgAuth;
 406+ global $wgMemc, $wgAuth;
407407
408408 wfProfileIn( __METHOD__ );
409409

Follow-up revisions

RevisionCommit summaryAuthorDate
r108490Readding a property that was removed in r71290johnduhart03:23, 10 January 2012

Status & tagging log