r75674 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75673‎ | r75674 | r75675 >
Date:21:08, 29 October 2010
Author:reedy
Status:deferred
Tags:
Comment:
Nuke unused globals

Fix a wrong usage of $this->viewPage to $viewPage
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialBannerAllocation.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialBannerController.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialNoticeTemplate.php (modified) (history)
  • /trunk/extensions/CentralNotice/TemplatePager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/CentralNotice.php
@@ -142,7 +142,7 @@
143143 }
144144
145145 function efCentralNoticeLoader( $out, $skin ) {
146 - global $wgUser, $wgOut, $wgCentralDBname, $wgScript;
 146+ global $wgOut;
147147
148148 // Include '.js' to exempt script from squid cache override
149149 $centralLoader = SpecialPage::getTitleFor( 'BannerController' )->getLocalUrl( 'cache=/cn.js' );
Index: trunk/extensions/CentralNotice/TemplatePager.php
@@ -54,7 +54,6 @@
5555 }
5656
5757 // Link and Preview
58 - $viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' );
5958 $render = new SpecialBannerLoader();
6059 $render->siteName = 'Wikipedia';
6160 $render->language = $this->mRequest->getVal( 'wpUserLanguage' );
Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -203,7 +203,7 @@
204204 $dbr = wfGetDB( DB_SLAVE );
205205 $res = $dbr->select( 'cn_notices', 'not_name', null, __METHOD__ );
206206 $notices = array();
207 - while ( $row = $dbr->fetchObject( $res ) ) {
 207+ foreach ( $res as $row ) {
208208 $notices[] = $row->not_name;
209209 }
210210 return $notices;
@@ -350,7 +350,7 @@
351351 $htmlOut .= $this->tableRow( $headers, 'th' );
352352
353353 // Table rows
354 - while ( $row = $dbr->fetchObject( $res ) ) {
 354+ foreach ( $res as $row ) {
355355 $fields = array();
356356
357357 // Name
@@ -362,7 +362,6 @@
363363 $fields[] = htmlspecialchars( $this->getProjectName( $row->not_project ) );
364364
365365 // Languages
366 - $project_langs = array();
367366 $project_langs = $this->getNoticeLanguages( $row->not_name );
368367 $language_count = count( $project_langs );
369368 $languageList = '';
@@ -429,7 +428,7 @@
430429 $htmlOut .= Xml::closeElement( 'table' );
431430
432431 if ( $this->editable ) {
433 - $htmlOut .= Xml::hidden( 'authtoken', $wgUser->editToken() );
 432+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
434433 $htmlOut .= Xml::openElement( 'div', array( 'class' => 'cn-buttons' ) );
435434 $htmlOut .= Xml::submitButton( wfMsg( 'centralnotice-modify' ),
436435 array(
@@ -703,7 +702,7 @@
704703 }
705704 }
706705 if ( $this->editable ) {
707 - $htmlOut .= Xml::hidden( 'authtoken', $wgUser->editToken() );
 706+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
708707
709708 // Submit button
710709 $htmlOut .= Xml::tags( 'div',
@@ -917,7 +916,7 @@
918917 wfMsg ( "centralnotice-templates" ) );
919918
920919 // Table rows
921 - while ( $row = $dbr->fetchObject( $res ) ) {
 920+ foreach( $res as $row ) {
922921
923922 $htmlOut .= Xml::openElement( 'tr' );
924923
@@ -1076,8 +1075,6 @@
10771076 }
10781077
10791078 function addNotice( $noticeName, $enabled, $start, $project_name, $project_languages, $geotargeted, $geo_countries ) {
1080 - global $wgOut;
1081 -
10821079 if ( $this->noticeExists( $noticeName ) ) {
10831080 $this->showError( 'centralnotice-notice-exists' );
10841081 return;
@@ -1136,7 +1133,6 @@
11371134 }
11381135
11391136 function removeNotice( $noticeName ) {
1140 - global $wgOut;
11411137 $dbr = wfGetDB( DB_SLAVE );
11421138
11431139 $res = $dbr->select( 'cn_notices', 'not_name, not_locked',
@@ -1163,8 +1159,6 @@
11641160 }
11651161
11661162 function addTemplateTo( $noticeName, $templateName, $weight ) {
1167 - global $wgOut;
1168 -
11691163 $dbr = wfGetDB( DB_SLAVE );
11701164
11711165 $eNoticeName = htmlspecialchars ( $noticeName );
@@ -1261,8 +1255,6 @@
12621256 }
12631257
12641258 function updateNoticeDate( $noticeName, $start, $end ) {
1265 - global $wgOut;
1266 -
12671259 $dbr = wfGetDB( DB_SLAVE );
12681260
12691261 // Start/end don't line up
@@ -1295,8 +1287,6 @@
12961288 * Update the enabled/disabled state of a campaign
12971289 */
12981290 private function updateEnabled( $noticeName, $isEnabled ) {
1299 - global $wgOut;
1300 -
13011291 if ( !$this->noticeExists( $noticeName ) ) {
13021292 $this->showError( 'centralnotice-doesnt-exist' );
13031293 } else {
@@ -1329,8 +1319,6 @@
13301320 * Update the geotargeted/not geotargeted state of a campaign
13311321 */
13321322 function updateGeotargeted( $noticeName, $isGeotargeted ) {
1333 - global $wgOut;
1334 -
13351323 if ( !$this->noticeExists( $noticeName ) ) {
13361324 $this->showError( 'centralnotice-doesnt-exist' );
13371325 } else {
@@ -1346,8 +1334,6 @@
13471335 * Update the locked/unlocked state of a campaign
13481336 */
13491337 function updateLock( $noticeName, $isLocked ) {
1350 - global $wgOut;
1351 -
13521338 if ( !$this->noticeExists( $noticeName ) ) {
13531339 $this->showError( 'centralnotice-doesnt-exist' );
13541340 } else {
@@ -1457,7 +1443,6 @@
14581444 $dbw->begin();
14591445
14601446 // Get the previously assigned languages
1461 - $oldLanguages = array();
14621447 $oldLanguages = $this->getNoticeLanguages( $notice );
14631448
14641449 // Get the notice id
@@ -1638,7 +1623,7 @@
16391624 $render->siteName = 'Wikipedia';
16401625 $render->language = $this->mRequest->getVal( 'wpUserLanguage' );
16411626 $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
1642 - $this->getSkin()->makeLinkObj( $this->viewPage,
 1627+ $this->getSkin()->makeLinkObj( $viewPage,
16431628 htmlspecialchars( $row->tmp_name ),
16441629 'template=' . urlencode( $row->tmp_name ) ) .
16451630 Xml::fieldset( wfMsg( 'centralnotice-preview' ),
@@ -1679,7 +1664,6 @@
16801665 * Close table
16811666 */
16821667 function getEndBody() {
1683 - global $wgUser;
16841668 $htmlOut = '';
16851669 $htmlOut .= Xml::closeElement( 'table' );
16861670 return $htmlOut;
Index: trunk/extensions/CentralNotice/SpecialBannerController.php
@@ -13,8 +13,7 @@
1414 }
1515
1616 function execute( $par ) {
17 - global $wgOut, $wgRequest;
18 - global $wgNoticeLang, $wgNoticeProject;
 17+ global $wgOut;
1918
2019 $wgOut->disable();
2120 $this->sendHeaders();
@@ -26,7 +25,6 @@
2726 } else {
2827 echo $content;
2928 }
30 -
3129 }
3230
3331 /**
Index: trunk/extensions/CentralNotice/SpecialBannerAllocation.php
@@ -19,7 +19,7 @@
2020 * Handle different types of page requests
2121 */
2222 function execute( $sub ) {
23 - global $wgOut, $wgUser, $wgRequest, $wgExtensionAssetsPath, $wgNoticeProjects, $wgLanguageCode;
 23+ global $wgOut, $wgRequest, $wgExtensionAssetsPath, $wgNoticeProjects, $wgLanguageCode;
2424
2525 if ( $wgRequest->wasPosted() ) {
2626 $this->project = $wgRequest->getText( 'project', 'wikipedia' );
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
@@ -618,8 +618,6 @@
619619 }
620620
621621 private function removeTemplate ( $name ) {
622 - global $wgOut;
623 -
624622 $id = $this->getTemplateId( $name );
625623 $dbr = wfGetDB( DB_SLAVE );
626624 $res = $dbr->select( 'cn_assignments', 'asn_id', array( 'tmp_id' => $id ), __METHOD__ );
@@ -647,8 +645,6 @@
648646 * Create a new banner
649647 */
650648 private function addTemplate( $name, $body, $displayAnon, $displayAccount ) {
651 - global $wgOut;
652 -
653649 if ( $body == '' || $name == '' ) {
654650 $this->showError( 'centralnotice-null-string' );
655651 return;
@@ -692,8 +688,6 @@
693689 * Update a banner
694690 */
695691 private function editTemplate( $name, $body, $displayAnon, $displayAccount ) {
696 - global $wgOut;
697 -
698692 if ( $body == '' || $name == '' ) {
699693 $this->showError( 'centralnotice-null-string' );
700694 return;
@@ -772,7 +766,6 @@
773767 * Find all message fields set for a banner
774768 */
775769 private function findFields( $template ) {
776 - $messages = array();
777770 $body = wfMsg( "Centralnotice-template-{$template}" );
778771
779772 // Generate list of message fields from parsing the body

Follow-up revisions

RevisionCommit summaryAuthorDate
r76145finishing clean-up from r75674kaldari21:47, 5 November 2010

Status & tagging log