Merge "Make sure that SQLite uses no prefix"
[lhc/web/wiklou.git] / includes / diff / DifferenceEngine.php
index 18dcfe9..0295f77 100644 (file)
@@ -522,8 +522,10 @@ class DifferenceEngine extends ContextSource {
                                if ( ContentHandler::runLegacyHooks( 'ShowRawCssJs', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
                                        // NOTE: deprecated hook, B/C only
                                        // use the content object's own rendering
-                                       $po = $this->mNewRev->getContent()->getParserOutput( $this->mNewRev->getTitle(), $this->mNewRev->getId() );
-                                       $out->addHTML( $po->getText() );
+                                       $cnt = $this->mNewRev->getContent();
+                                       $po = $cnt ? $cnt->getParserOutput( $this->mNewRev->getTitle(), $this->mNewRev->getId() ) : null;
+                                       $txt = $po ? $po->getText() : '';
+                                       $out->addHTML( $txt );
                                }
                        } elseif( !wfRunHooks( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
                                // Handled by extension
@@ -544,8 +546,19 @@ class DifferenceEngine extends ContextSource {
 
                                $parserOutput = $this->getParserOutput( $wikiPage, $this->mNewRev );
 
-                               # WikiPage::getParserOutput() should not return false, but just in case
-                               if( $parserOutput ) {
+                               # Also try to load it as a redirect
+                               $rt = $this->mNewContent ? $this->mNewContent->getRedirectTarget() : null;
+
+                               if ( $rt ) {
+                                       $article = Article::newFromTitle( $this->mNewPage, $this->getContext() );
+                                       $out->addHTML( $article->viewRedirect( $rt ) );
+
+                                       # WikiPage::getParserOutput() should not return false, but just in case
+                                       if ( $parserOutput ) {
+                                               # Show categories etc.
+                                               $out->addParserOutputNoText( $parserOutput );
+                                       }
+                               } else if ( $parserOutput ) {
                                        $out->addParserOutput( $parserOutput );
                                }
                        }
@@ -703,12 +716,19 @@ class DifferenceEngine extends ContextSource {
        /**
         * Generate a diff, no caching.
         *
-        * Subclasses may override this to provide a
+        * This implementation uses generateTextDiffBody() to generate a diff based on the default
+        * serialization of the given Content objects. This will fail if $old or $new are not
+        * instances of TextContent.
+        *
+        * Subclasses may override this to provide a different rendering for the diff,
+        * perhaps taking advantage of the content's native form. This is required for all content
+        * models that are not text based.
         *
         * @param $old Content: old content
         * @param $new Content: new content
         *
         * @since 1.21
+        * @throws MWException if $old or $new are not instances of TextContent.
         */
        function generateContentDiffBody( Content $old, Content $new ) {
                if ( !( $old instanceof TextContent ) ) {
@@ -735,7 +755,7 @@ class DifferenceEngine extends ContextSource {
         * @deprecated since 1.21, use generateContentDiffBody() instead!
         */
        function generateDiffBody( $otext, $ntext ) {
-               wfDeprecated( __METHOD__, "1.21" );
+               ContentHandler::deprecated( __METHOD__, "1.21" );
 
                return $this->generateTextDiffBody( $otext, $ntext );
        }
@@ -1007,7 +1027,7 @@ class DifferenceEngine extends ContextSource {
         * @deprecated since 1.21, use setContent() instead.
         */
        function setText( $oldText, $newText ) {
-               wfDeprecated( __METHOD__, "1.21" );
+               ContentHandler::deprecated( __METHOD__, "1.21" );
 
                $oldContent = ContentHandler::makeContent( $oldText, $this->getTitle() );
                $newContent = ContentHandler::makeContent( $newText, $this->getTitle() );
@@ -1151,13 +1171,13 @@ class DifferenceEngine extends ContextSource {
                }
                if ( $this->mOldRev ) {
                        $this->mOldContent = $this->mOldRev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
-                       if ( $this->mOldContent === false ) {
+                       if ( $this->mOldContent === null ) {
                                return false;
                        }
                }
                if ( $this->mNewRev ) {
                        $this->mNewContent = $this->mNewRev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
-                       if ( $this->mNewContent === false ) {
+                       if ( $this->mNewContent === null ) {
                                return false;
                        }
                }