r75332 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75331‎ | r75332 | r75333 >
Date:18:57, 24 October 2010
Author:pdhanda
Status:resolved (Comments)
Tags:
Comment:
bug25289 Hook that optionally adds custom content instead of article content on diff pages. Now only used by FlaggedRevs to not load the content on history pages when pending changes are enabled.
Modified paths:
  • /trunk/phase3/includes/diff/DifferenceInterface.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/diff/DifferenceInterface.php
@@ -456,21 +456,24 @@
457457 $wgOut->addHTML( htmlspecialchars( $this->mNewtext ) );
458458 $wgOut->addHTML( "\n</pre>\n" );
459459 }
460 - } elseif( $pCache ) {
461 - $article = new Article( $this->mTitle, 0 );
462 - $pOutput = ParserCache::singleton()->get( $article, $wgOut->parserOptions() );
463 - if( $pOutput ) {
464 - $wgOut->addParserOutput( $pOutput );
 460+ } elseif( wfRunHooks( 'ArticleContentOnDiff', array( $this, &$wgOut ) ) ) {
 461+ //TODO: document this hook
 462+ if( $pCache ) {
 463+ $article = new Article( $this->mTitle, 0 );
 464+ $pOutput = ParserCache::singleton()->get( $article, $wgOut->parserOptions() );
 465+ if( $pOutput ) {
 466+ $wgOut->addParserOutput( $pOutput );
 467+ } else {
 468+ $article->doViewParse();
 469+ }
465470 } else {
466 - $article->doViewParse();
 471+ $wgOut->addWikiTextTidy( $this->mNewtext );
467472 }
468 - } else {
469 - $wgOut->addWikiTextTidy( $this->mNewtext );
 473+ if( is_object( $this->mNewRev ) && !$this->mNewRev->isCurrent() ) {
 474+ $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting );
 475+ }
470476 }
471 -
472 - if( is_object( $this->mNewRev ) && !$this->mNewRev->isCurrent() ) {
473 - $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting );
474 - }
 477+
475478 # Add redundant patrol link on bottom...
476479 if( $this->mRcidMarkPatrolled && $this->mTitle->quickUserCan('patrol') ) {
477480 $sk = $wgUser->getSkin();

Follow-up revisions

RevisionCommit summaryAuthorDate
r75481Address my own CR in r75332.platonides22:34, 26 October 2010
r76444MFT r75332, r75481: Adding hook for changing content on diff pagesdemon15:03, 10 November 2010

Comments

#Comment by Reedy (talk | contribs)   19:17, 24 October 2010

You seem to need the spaces "bug 25289"

#Comment by Platonides (talk | contribs)   16:26, 25 October 2010
  • Seems I had the wfRunHooks condition reversed :)
  • $wgOut is an object. Why are you passing it as reference?
  • Space lost between "if" and "( $pCache"
  • The setEditSection() is restoring the options changed in line 439. I find that moving it inside the if is wrong. Instead I would move 439 (and the restore) inside the if ( $pCache ).
  • $wgOut->addWikiTextTidy has one tab too much.
  • And the TODO should be fixed.
#Comment by Platonides (talk | contribs)   22:34, 26 October 2010

I addressed them in r75481.

Status & tagging log