(Bug 41179) Missing content in EditPage::showDiff
authordaniel <daniel.kinzler@wikimedia.de>
Thu, 18 Oct 2012 17:37:26 +0000 (19:37 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Thu, 18 Oct 2012 17:37:26 +0000 (19:37 +0200)
Fixing another instance where the page content may be null.

Change-Id: I2f377937892dcfa5389f768edfb6033d2e6196b4

includes/EditPage.php

index 4a1e517..8f9d394 100644 (file)
@@ -2602,16 +2602,26 @@ HTML
                                                        $this->section, $textboxContent,
                                                        $this->summary, $this->edittime );
 
-               ContentHandler::runLegacyHooks( 'EditPageGetDiffText', array( $this, &$newContent ) );
-               wfRunHooks( 'EditPageGetDiffContent', array( $this, &$newContent ) );
+               if ( $newContent ) {
+                       ContentHandler::runLegacyHooks( 'EditPageGetDiffText', array( $this, &$newContent ) );
+                       wfRunHooks( 'EditPageGetDiffContent', array( $this, &$newContent ) );
 
-               $popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang );
-               $newContent = $newContent->preSaveTransform( $this->mTitle, $wgUser, $popts );
+                       $popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang );
+                       $newContent = $newContent->preSaveTransform( $this->mTitle, $wgUser, $popts );
+               }
 
                if ( ( $oldContent && !$oldContent->isEmpty() ) || ( $newContent && !$newContent->isEmpty() ) ) {
                        $oldtitle = wfMessage( $oldtitlemsg )->parse();
                        $newtitle = wfMessage( 'yourtext' )->parse();
 
+                       if ( !$oldContent ) {
+                               $oldContent = $newContent->getContentHandler()->makeEmptyContent();
+                       }
+
+                       if ( !$newContent ) {
+                               $newContent = $oldContent->getContentHandler()->makeEmptyContent();
+                       }
+
                        $de = $oldContent->getContentHandler()->createDifferenceEngine( $this->mArticle->getContext() );
                        $de->setContent( $oldContent, $newContent );