Improved BagOStuff docs.
[lhc/web/wiklou.git] / includes / diff / DifferenceEngine.php
index f3dc5a3..97553e6 100644 (file)
@@ -38,6 +38,9 @@ class DifferenceEngine extends ContextSource {
         * @private
         */
        var $mOldid, $mNewid;
+       /**
+        * @var Content
+        */
        var $mOldContent, $mNewContent;
        protected $mDiffLang;
 
@@ -291,8 +294,11 @@ class DifferenceEngine extends ContextSource {
 
                        if ( $samePage && $this->mNewPage->quickUserCan( 'edit', $user ) ) {
                                if ( $this->mNewRev->isCurrent() && $this->mNewPage->userCan( 'rollback', $user ) ) {
-                                       $out->preventClickjacking();
-                                       $rollback = '   ' . Linker::generateRollback( $this->mNewRev, $this->getContext() );
+                                       $rollbackLink = Linker::generateRollback( $this->mNewRev, $this->getContext() );
+                                       if ( $rollbackLink ) {
+                                               $out->preventClickjacking();
+                                               $rollback = '   ' . $rollbackLink;
+                                       }
                                }
                                if ( !$this->mOldRev->isDeleted( Revision::DELETED_TEXT ) && !$this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
                                        $undoLink = ' ' . $this->msg( 'parentheses' )->rawParams(
@@ -421,8 +427,8 @@ class DifferenceEngine extends ContextSource {
        /**
         * Get a link to mark the change as patrolled, or '' if there's either no
         * revision to patrol or the user is not allowed to to it.
-        * Side effect: this method will call OutputPage::preventClickjacking()
-        * when a link is builded.
+        * Side effect: When the patrol link is build, this method will call
+        * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
         *
         * @return String
         */
@@ -463,6 +469,8 @@ class DifferenceEngine extends ContextSource {
                                // Build the link
                                if ( $rcid ) {
                                        $this->getOutput()->preventClickjacking();
+                                       $this->getOutput()->addModules( 'mediawiki.page.patrol.ajax' );
+
                                        $token = $this->getUser()->getEditToken( $rcid );
                                        $this->mMarkPatrolledLink = ' <span class="patrollink">[' . Linker::linkKnown(
                                                $this->mNewPage,
@@ -522,8 +530,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
@@ -545,7 +555,7 @@ class DifferenceEngine extends ContextSource {
                                $parserOutput = $this->getParserOutput( $wikiPage, $this->mNewRev );
 
                                # Also try to load it as a redirect
-                               $rt = $this->mNewContent->getRedirectTarget();
+                               $rt = $this->mNewContent ? $this->mNewContent->getRedirectTarget() : null;
 
                                if ( $rt ) {
                                        $article = Article::newFromTitle( $this->mNewPage, $this->getContext() );
@@ -606,8 +616,8 @@ class DifferenceEngine extends ContextSource {
        /**
         * Get complete diff table, including header
         *
-        * @param $otitle Title: old title
-        * @param $ntitle Title: new title
+        * @param string|bool $otitle Header for old text or false
+        * @param string|bool $ntitle Header for new text or false
         * @param $notice String: HTML between diff header and body
         * @return mixed
         */
@@ -1169,13 +1179,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;
                        }
                }