r108110 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108109‎ | r108110 | r108111 >
Date:01:48, 5 January 2012
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Update deprecated code

Fix some inconsistant returns

Remove unused globals
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNoticeBannerLogPager.php (modified) (history)
  • /trunk/extensions/CentralNotice/CentralNoticeCampaignLogPager.php (modified) (history)
  • /trunk/extensions/CentralNotice/CentralNoticePageLogPager.php (modified) (history)
  • /trunk/extensions/CentralNotice/TemplatePager.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialBannerAllocation.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialBannerLoader.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialCentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php
@@ -17,7 +17,7 @@
1818 * Handle different types of page requests
1919 */
2020 function execute( $sub ) {
21 - global $wgOut, $wgUser, $wgRequest, $wgExtensionAssetsPath;
 21+ global $wgOut, $wgUser, $wgRequest;
2222
2323 // Begin output
2424 $this->setHeaders();
@@ -319,7 +319,7 @@
320320
321321 // Get connection
322322 $dbr = wfGetDB( DB_SLAVE );
323 - $sk = $wgUser->getSkin();
 323+ $sk = $this->getSkin();
324324 if ( $this->editable ) {
325325 $readonly = array();
326326 } else {
@@ -480,7 +480,7 @@
481481 $htmlOut .= Xml::closeElement( 'table' );
482482
483483 if ( $this->editable ) {
484 - $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
 484+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->getEditToken() );
485485 $htmlOut .= Xml::openElement( 'div', array( 'class' => 'cn-buttons' ) );
486486 $htmlOut .= Xml::submitButton( wfMsg( 'centralnotice-modify' ),
487487 array(
@@ -576,7 +576,7 @@
577577
578578 $htmlOut .= Xml::closeElement( 'table' );
579579 $htmlOut .= Html::hidden( 'change', 'weight' );
580 - $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
 580+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->getEditToken() );
581581
582582 // Submit button
583583 $htmlOut .= Xml::tags( 'div',
@@ -758,7 +758,7 @@
759759 $htmlOut .= wfMsg( 'centralnotice-no-templates' );
760760 $htmlOut .= Xml::element( 'p' );
761761 $newPage = $this->getTitleFor( 'NoticeTemplate', 'add' );
762 - $sk = $wgUser->getSkin();
 762+ $sk = $this->getSkin();
763763 $htmlOut .= $sk->makeLinkObj( $newPage, wfMsgHtml( 'centralnotice-add-template' ) );
764764 $htmlOut .= Xml::element( 'p' );
765765 } elseif ( $output_assigned == '' ) {
@@ -775,7 +775,7 @@
776776 }
777777 }
778778 if ( $this->editable ) {
779 - $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
 779+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->getEditToken() );
780780
781781 // Submit button
782782 $htmlOut .= Xml::tags( 'div',
@@ -951,8 +951,7 @@
952952 * Create form for managing banners assigned to a campaign
953953 */
954954 function assignedTemplatesForm( $notice ) {
955 - global $wgUser;
956 - $sk = $wgUser->getSkin();
 955+ $sk = $this->getSkin();
957956
958957 $dbr = wfGetDB( DB_SLAVE );
959958 $res = $dbr->select(
@@ -977,7 +976,7 @@
978977
979978 // No banners found
980979 if ( $dbr->numRows( $res ) < 1 ) {
981 - return;
 980+ return '';
982981 }
983982
984983 // Build Assigned banners HTML
@@ -1067,9 +1066,10 @@
10681067 $dbr = wfGetDB( DB_SLAVE );
10691068 $res = $dbr->select( 'cn_templates', 'tmp_name', '', '', array( 'ORDER BY' => 'tmp_id' ) );
10701069
 1070+ $htmlOut = '';
10711071 if ( $dbr->numRows( $res ) > 0 ) {
10721072 // Build HTML
1073 - $htmlOut = Xml::fieldset( wfMsg( "centralnotice-available-templates" ) );
 1073+ $htmlOut = Xml::fieldset( wfMsg( "centralnotice-available-templates" ) );
10741074
10751075 // Show paginated list of banners
10761076 $htmlOut .= Xml::tags( 'div',
@@ -1081,9 +1081,6 @@
10821082 $pager->getNavigationBar() );
10831083
10841084 $htmlOut .= Xml::closeElement( 'fieldset' );
1085 - } else {
1086 - // Nothing found
1087 - return;
10881085 }
10891086 return $htmlOut;
10901087 }
Index: trunk/extensions/CentralNotice/special/SpecialBannerAllocation.php
@@ -14,10 +14,8 @@
1515 * Handle different types of page requests
1616 */
1717 function execute( $sub ) {
18 - global $wgOut, $wgLang, $wgRequest, $wgExtensionAssetsPath, $wgNoticeProjects, $wgLanguageCode, $wgNoticeProject;
 18+ global $wgOut, $wgLang, $wgRequest, $wgNoticeProjects, $wgLanguageCode, $wgNoticeProject;
1919
20 - $locationSubmitted = false;
21 -
2220 $this->project = $wgRequest->getText( 'project', $wgNoticeProject );
2321 $this->language = $wgRequest->getText( 'language', $wgLanguageCode );
2422
@@ -208,9 +206,9 @@
209207 }
210208
211209 function getTable( $type, $banners, $weight ) {
212 - global $wgUser, $wgLang;
 210+ global $wgLang;
213211
214 - $sk = $wgUser->getSkin();
 212+ $sk = $this->getSkin();
215213 $viewBanner = $this->getTitleFor( 'NoticeTemplate', 'view' );
216214 $viewCampaign = $this->getTitleFor( 'CentralNotice' );
217215
Index: trunk/extensions/CentralNotice/special/SpecialBannerLoader.php
@@ -81,6 +81,7 @@
8282 $bannerJs = 'insertBanner('.FormatJson::encode( $bannerArray ).');';
8383 return $bannerJs;
8484 }
 85+ return '';
8586 }
8687
8788 /**
@@ -99,6 +100,7 @@
100101 );
101102 return $bannerHtml;
102103 }
 104+ return '';
103105 }
104106
105107 /**
Index: trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php
@@ -17,7 +17,7 @@
1818 * Handle different types of page requests
1919 */
2020 function execute( $sub ) {
21 - global $wgOut, $wgUser, $wgRequest, $wgExtensionAssetsPath;
 21+ global $wgOut, $wgUser, $wgRequest;
2222
2323 // Begin output
2424 $this->setHeaders();
@@ -166,9 +166,9 @@
167167 * Show a list of available banners. Newer banners are shown first.
168168 */
169169 function showList() {
170 - global $wgOut, $wgUser;
 170+ global $wgOut;
171171
172 - $sk = $wgUser->getSkin();
 172+ $sk = $this->getSkin();
173173 $pager = new TemplatePager( $this );
174174
175175 // Begin building HTML
@@ -305,7 +305,7 @@
306306
307307 $htmlOut .= Xml::textarea( 'templateBody', $body, 60, 20 );
308308 $htmlOut .= Html::closeElement( 'fieldset' );
309 - $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
 309+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->getEditToken() );
310310
311311 // Submit button
312312 $htmlOut .= Xml::tags( 'div',
@@ -328,7 +328,7 @@
329329 $wgNoticeEnableFundraising;
330330
331331 $scriptPath = "$wgExtensionAssetsPath/CentralNotice";
332 - $sk = $wgUser->getSkin();
 332+ $sk = $this->getSkin();
333333
334334 if ( $this->editable ) {
335335 $readonly = array();
@@ -490,7 +490,7 @@
491491
492492 if ( $this->editable ) {
493493 $htmlOut .= Html::hidden( 'wpUserLanguage', $wpUserLang );
494 - $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
 494+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->getEditToken() );
495495 $htmlOut .= Xml::tags( 'div',
496496 array( 'class' => 'cn-buttons' ),
497497 Xml::submitButton(
@@ -640,7 +640,7 @@
641641 if ( $this->editable ) {
642642 // Indicate which form was submitted
643643 $htmlOut .= Html::hidden( 'mainform', 'true' );
644 - $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
 644+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->getEditToken() );
645645 $htmlOut .= Xml::tags( 'div',
646646 array( 'class' => 'cn-buttons' ),
647647 Xml::submitButton( wfMsg( 'centralnotice-save-banner' ) )
@@ -670,7 +670,7 @@
671671
672672 $htmlOut .= Html::closeElement( 'tr' );
673673 $htmlOut .= Html::closeElement( 'table' );
674 - $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
 674+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->getEditToken() );
675675 $htmlOut .= Html::closeElement( 'fieldset' );
676676 $htmlOut .= Html::closeElement( 'form' );
677677 }
@@ -692,7 +692,7 @@
693693 // Testing to see if bumping up the memory limit lets meta preview
694694 ini_set( 'memory_limit', '120M' );
695695
696 - $sk = $wgUser->getSkin();
 696+ $sk = $this->getSkin();
697697
698698 // Pull all available text for a banner
699699 $langs = array_keys( $this->getTranslations( $template ) );
Index: trunk/extensions/CentralNotice/TemplatePager.php
@@ -106,7 +106,7 @@
107107 $htmlOut = '';
108108 $htmlOut .= Xml::closeElement( 'table' );
109109 if ( $this->editable ) {
110 - $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
 110+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->getEditToken() );
111111 $htmlOut .= Xml::tags( 'div',
112112 array( 'class' => 'cn-buttons' ),
113113 Xml::submitButton( wfMsg( 'centralnotice-modify' ) )
Index: trunk/extensions/CentralNotice/CentralNoticeBannerLogPager.php
@@ -132,7 +132,6 @@
133133 }
134134
135135 function showInitialSettings( $row ) {
136 - global $wgLang;
137136 $details = '';
138137 $details .= wfMsg (
139138 'centralnotice-log-label',
@@ -165,9 +164,7 @@
166165 }
167166
168167 function showChanges( $row ) {
169 - global $wgLang;
170 - $details = '';
171 - $details .= $this->testBooleanChange( 'anon', $row );
 168+ $details = $this->testBooleanChange( 'anon', $row );
172169 $details .= $this->testBooleanChange( 'account', $row );
173170 $details .= $this->testBooleanChange( 'fundraising', $row );
174171 $details .= $this->testBooleanChange( 'autolink', $row );
Index: trunk/extensions/CentralNotice/CentralNoticePageLogPager.php
@@ -59,8 +59,6 @@
6060 * Generate the content of each table row (1 row = 1 log entry)
6161 */
6262 function formatRow( $row ) {
63 - global $wgLang, $wgExtensionAssetsPath;
64 -
6563 // Create a user object so we can pull the name, user page, etc.
6664 $loggedUser = User::newFromId( $row->rc_user );
6765 // Create the user page link
Index: trunk/extensions/CentralNotice/CentralNoticeCampaignLogPager.php
@@ -4,7 +4,6 @@
55 var $viewPage, $special;
66
77 function __construct( $special ) {
8 - global $wgRequest;
98 $this->special = $special;
109 parent::__construct();
1110

Follow-up revisions

RevisionCommit summaryAuthorDate
r108555follow-up to r108110 - making 1.18wmf compatkaldari22:33, 10 January 2012
r108681follow-up to r108110 - re-adding needed global var; also fixing fatal error o...kaldari21:31, 11 January 2012

Comments

#Comment by Kaldari (talk | contribs)   22:10, 10 January 2012

These changes are a bit premature. getEditToken(), for example, doesn't exist in 1.18wmf (the current live version). We're planning on doing at least one more deploy of CentralNotice before February, so the extension needs to be 1.18wmf compatible.

#Comment by Kaldari (talk | contribs)   22:36, 10 January 2012

Fixed in r108555.

Status & tagging log