r94089 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94088‎ | r94089 | r94090 >
Date:21:07, 8 August 2011
Author:ialex
Status:ok
Tags:
Comment:
Use local context instead of global variables
Modified paths:
  • /trunk/phase3/includes/QueryPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/QueryPage.php
@@ -437,24 +437,23 @@
438438 * real, honest-to-gosh query page.
439439 */
440440 function execute( $par ) {
441 - global $wgUser, $wgOut, $wgLang, $wgRequest;
442 -
443 - if ( !$this->userCanExecute( $wgUser ) ) {
 441+ if ( !$this->userCanExecute( $this->getUser() ) ) {
444442 $this->displayRestrictionError();
445443 return;
446444 }
447445
448446 if ( $this->limit == 0 && $this->offset == 0 ) {
449 - list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset();
 447+ list( $this->limit, $this->offset ) = $this->getRequest()->getLimitOffset();
450448 }
451449 $dbr = wfGetDB( DB_SLAVE );
452450
453451 $this->setHeaders();
454 - $wgOut->setSyndicated( $this->isSyndicated() );
 452+ $out = $this->getOutput();
 453+ $out->setSyndicated( $this->isSyndicated() );
455454
456455 if ( $this->isCached() && !$this->isCacheable() ) {
457 - $wgOut->setSyndicated( false );
458 - $wgOut->addWikiMsg( 'querypage-disabled' );
 456+ $out->setSyndicated( false );
 457+ $out->addWikiMsg( 'querypage-disabled' );
459458 return 0;
460459 }
461460
@@ -471,21 +470,22 @@
472471 $ts = $this->getCachedTimestamp();
473472
474473 if ( $ts ) {
475 - $updated = $wgLang->timeanddate( $ts, true, true );
476 - $updateddate = $wgLang->date( $ts, true, true );
477 - $updatedtime = $wgLang->time( $ts, true, true );
478 - $wgOut->addMeta( 'Data-Cache-Time', $ts );
479 - $wgOut->addInlineScript( "var dataCacheTime = '$ts';" );
480 - $wgOut->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime );
 474+ $lang = $this->getLang();
 475+ $updated = $lang->timeanddate( $ts, true, true );
 476+ $updateddate = $lang->date( $ts, true, true );
 477+ $updatedtime = $lang->time( $ts, true, true );
 478+ $out->addMeta( 'Data-Cache-Time', $ts );
 479+ $out->addInlineScript( "var dataCacheTime = '$ts';" );
 480+ $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime );
481481 } else {
482 - $wgOut->addWikiMsg( 'perfcached' );
 482+ $out->addWikiMsg( 'perfcached' );
483483 }
484484
485485 # If updates on this page have been disabled, let the user know
486486 # that the data set won't be refreshed for now
487487 global $wgDisableQueryPageUpdate;
488488 if ( is_array( $wgDisableQueryPageUpdate ) && in_array( $this->getName(), $wgDisableQueryPageUpdate ) ) {
489 - $wgOut->addWikiMsg( 'querypage-no-updates' );
 489+ $out->addWikiMsg( 'querypage-no-updates' );
490490 }
491491
492492 }
@@ -496,23 +496,23 @@
497497
498498 $this->preprocessResults( $dbr, $res );
499499
500 - $wgOut->addHTML( Xml::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) );
 500+ $out->addHTML( Xml::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) );
501501
502502 # Top header and navigation
503503 if ( $this->shownavigation ) {
504 - $wgOut->addHTML( $this->getPageHeader() );
 504+ $out->addHTML( $this->getPageHeader() );
505505 if ( $this->numRows > 0 ) {
506 - $wgOut->addHTML( '<p>' . wfShowingResults( $this->offset, $this->numRows ) . '</p>' );
 506+ $out->addHTML( '<p>' . wfShowingResults( $this->offset, $this->numRows ) . '</p>' );
507507 # Disable the "next" link when we reach the end
508508 $paging = wfViewPrevNext( $this->offset, $this->limit,
509509 $this->getTitle( $par ),
510510 wfArrayToCGI( $this->linkParameters() ), ( $this->numRows < $this->limit ) );
511 - $wgOut->addHTML( '<p>' . $paging . '</p>' );
 511+ $out->addHTML( '<p>' . $paging . '</p>' );
512512 } else {
513513 # No results to show, so don't bother with "showing X of Y" etc.
514514 # -- just let the user know and give up now
515 - $wgOut->addHTML( '<p>' . wfMsgHtml( 'specialpage-empty' ) . '</p>' );
516 - $wgOut->addHTML( Xml::closeElement( 'div' ) );
 515+ $out->addHTML( '<p>' . wfMsgHtml( 'specialpage-empty' ) . '</p>' );
 516+ $out->addHTML( Xml::closeElement( 'div' ) );
517517 return;
518518 }
519519 }
@@ -520,7 +520,7 @@
521521 # The actual results; specialist subclasses will want to handle this
522522 # with more than a straight list, so we hand them the info, plus
523523 # an OutputPage, and let them get on with it
524 - $this->outputResults( $wgOut,
 524+ $this->outputResults( $out,
525525 $this->getSkin(),
526526 $dbr, # Should use a ResultWrapper for this
527527 $res,
@@ -529,10 +529,10 @@
530530
531531 # Repeat the paging links at the bottom
532532 if ( $this->shownavigation ) {
533 - $wgOut->addHTML( '<p>' . $paging . '</p>' );
 533+ $out->addHTML( '<p>' . $paging . '</p>' );
534534 }
535535
536 - $wgOut->addHTML( Xml::closeElement( 'div' ) );
 536+ $out->addHTML( Xml::closeElement( 'div' ) );
537537
538538 return $this->numRows;
539539 }
@@ -617,8 +617,7 @@
618618 global $wgFeed, $wgFeedClasses;
619619
620620 if ( !$wgFeed ) {
621 - global $wgOut;
622 - $wgOut->addWikiMsg( 'feed-unavailable' );
 621+ $this->getOutput()->addWikiMsg( 'feed-unavailable' );
623622 return;
624623 }
625624
@@ -787,10 +786,9 @@
788787 * @return string
789788 */
790789 private function makeWlhLink( $title, $skin, $result ) {
791 - global $wgLang;
792790 $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
793791 $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ),
794 - $wgLang->formatNum( $result->value ) );
 792+ $this->getLang()->formatNum( $result->value ) );
795793 return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) );
796794 }
797795 }

Status & tagging log