r91584 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91583‎ | r91584 | r91585 >
Date:19:13, 6 July 2011
Author:aaron
Status:ok (Comments)
Tags:
Comment:
* Call viewRedirect() on Article (WikiPage doesn't inherit this anymore)
* Fixed bug 29734 - "categories on redirect pages don't appear on stable version"
* Fixed globalArticleInstance() to account for RequestContext stuff which broke it (it was loading the pre-redirected title)
* Renamed $parserOptions vars for briefity
Modified paths:
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php
@@ -283,6 +283,7 @@
284284 }
285285 # Environment (e.g. $wgTitle) will change in MediaWiki::initializeArticle
286286 if ( $clearEnvironment ) $view->clear();
 287+
287288 return true;
288289 }
289290
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedPageView.php
@@ -60,9 +60,9 @@
6161 * or false if there isn't such a title
6262 */
6363 public static function globalArticleInstance() {
64 - global $wgTitle;
65 - if ( !empty( $wgTitle ) ) {
66 - return FlaggedPage::getTitleInstance( $wgTitle );
 64+ $title = RequestContext::getMain()->getTitle();
 65+ if ( $title ) {
 66+ return FlaggedPage::getTitleInstance( $title );
6767 }
6868 return null;
6969 }
@@ -596,18 +596,21 @@
597597 }
598598 }
599599
600 - # Check if this is a redirect...
601600 $text = $frev->getRevText();
602 - $redirHtml = $this->getRedirectHtml( $text );
 601+ # Get the new stable parser output...
 602+ $pOpts = $this->article->makeParserOptions( $wgUser );
 603+ $parserOut = FlaggedRevs::parseStableText(
 604+ $this->article->getTitle(), $text, $frev->getRevId(), $pOpts );
603605
604606 # Parse and output HTML
605 - if ( $redirHtml == '' ) {
606 - $parserOptions = $this->article->makeParserOptions( $wgUser );
607 - $parserOut = FlaggedRevs::parseStableText(
608 - $this->article->getTitle(), $text, $frev->getRevId(), $parserOptions );
 607+ $redirHtml = $this->getRedirectHtml( $text );
 608+ if ( $redirHtml == '' ) { // page is not a redirect...
 609+ # Add the stable output to the page view
609610 $this->addParserOutput( $parserOut );
610 - } else {
 611+ } else { // page is a redirect...
611612 $this->out->addHtml( $redirHtml );
 613+ # Add output to set categories, displaytitle, etc.
 614+ $this->out->addParserOutputNoText( $parserOut );
612615 }
613616 }
614617
@@ -675,30 +678,31 @@
676679 }
677680
678681 # Get parsed stable version and output HTML
679 - $parserOptions = $this->article->makeParserOptions( $wgUser );
 682+ $pOpts = $this->article->makeParserOptions( $wgUser );
680683 $parserCache = FRParserCacheStable::singleton();
681 - $parserOut = $parserCache->get( $this->article, $parserOptions );
 684+ $parserOut = $parserCache->get( $this->article, $pOpts );
682685 if ( $parserOut ) {
 686+ # Cache hit. Note that redirects are not cached.
683687 $this->addParserOutput( $parserOut );
684688 } else {
685689 $text = $srev->getRevText();
686 - # Check if this is a redirect...
 690+ # Get the new stable parser output...
 691+ $parserOut = FlaggedRevs::parseStableText(
 692+ $this->article->getTitle(), $text, $srev->getRevId(), $pOpts );
 693+
687694 $redirHtml = $this->getRedirectHtml( $text );
688 - # Don't parse redirects, use separate handling...
689 - if ( $redirHtml == '' ) {
690 - # Get the new stable output
691 - $parserOut = FlaggedRevs::parseStableText(
692 - $this->article->getTitle(), $text, $srev->getRevId(), $parserOptions );
 695+ if ( $redirHtml == '' ) { // page is not a redirect...
693696 # Update the stable version cache
694 - $parserCache->save( $parserOut, $this->article, $parserOptions );
 697+ $parserCache->save( $parserOut, $this->article, $pOpts );
695698 # Add the stable output to the page view
696699 $this->addParserOutput( $parserOut );
697 -
698 - # Update the stable version dependancies
699 - FlaggedRevs::updateStableOnlyDeps( $this->article, $parserOut );
700 - } else {
 700+ } else { // page is a redirect...
701701 $this->out->addHtml( $redirHtml );
 702+ # Add output to set categories, displaytitle, etc.
 703+ $this->out->addParserOutputNoText( $parserOut );
702704 }
 705+ # Update the stable version dependancies
 706+ FlaggedRevs::updateStableOnlyDeps( $this->article, $parserOut );
703707 }
704708
705709 # Update page sync status for tracking purposes.
@@ -725,7 +729,8 @@
726730 protected function getRedirectHtml( $text ) {
727731 $rTargets = Title::newFromRedirectArray( $text );
728732 if ( $rTargets ) {
729 - return $this->article->viewRedirect( $rTargets );
 733+ $article = new Article( $this->article->getTitle() );
 734+ return $article->viewRedirect( $rTargets );
730735 }
731736 return '';
732737 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r92317REL1_18 FR: r87606, r87617, r87669, r87690, r87700, r90388, r90419, r90741, r...reedy21:53, 15 July 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   19:33, 6 July 2011

Tagged for porting to 1.18. Note that the change to account for WikiPage doesn't effect 1.18.

Status & tagging log