MaxSem has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/126880

Change subject: Fix "Call to undefined method 
ProofreadPageDifferenceEngine::getWarningMessageText()"
......................................................................

Fix "Call to undefined method 
ProofreadPageDifferenceEngine::getWarningMessageText()"

This is an emergency fix, the functions I've mercilessly killed should really 
be upstreamed into core

Change-Id: If2bd07397c4185c4facb951fc0326f5ac6b0fe19
---
M includes/diff/InlineDifferenceEngine.php
M includes/specials/SpecialMobileDiff.php
2 files changed, 42 insertions(+), 88 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/80/126880/1

diff --git a/includes/diff/InlineDifferenceEngine.php 
b/includes/diff/InlineDifferenceEngine.php
index 8fcb3a8..547df32 100644
--- a/includes/diff/InlineDifferenceEngine.php
+++ b/includes/diff/InlineDifferenceEngine.php
@@ -2,89 +2,6 @@
 
 class InlineDifferenceEngine extends DifferenceEngine {
        /**
-        * Checks whether the given Revision was deleted
-        * FIXME: Upstream to DifferenceEngine - refactor showDiffPage
-        *
-        * @return boolean
-        */
-       public function isDeletedDiff() {
-               return $this->mNewRev && $this->mNewRev->isDeleted( 
Revision::DELETED_TEXT );
-       }
-
-       /**
-        * Checks whether the given Revision was deleted or if it is delete
-        * restricted.
-        * FIXME: Upstream to DifferenceEngine - refactor showDiffPage
-        *
-        * @return boolean
-        */
-       public function isSuppressedDiff() {
-               return $this->isDeletedDiff() &&
-                       $this->mNewRev->isDeleted( Revision::DELETED_RESTRICTED 
);
-       }
-
-       /**
-        * Checks whether the current user has permission to view the old
-        * and current revisions.
-        * FIXME: Upstream to DifferenceEngine - refactor showDiffPage
-        *
-        * @return boolean
-        */
-       public function isUserAllowedToSee() {
-               $user = $this->getUser();
-               $allowed = $this->mNewRev->userCan( Revision::DELETED_TEXT, 
$user );
-               if ( $this->mOldRev &&
-                       !$this->mOldRev->userCan( Revision::DELETED_TEXT, $user 
)
-               ) {
-                       $allowed = false;
-               }
-               return $allowed;
-       }
-
-       /**
-        * Checks whether the diff should be hidden from the current user
-        * This is based on whether the user is allowed to see it and whether
-        * the flag unhide is set to allow viewing deleted revisions.
-        * FIXME: Upstream to DifferenceEngine - refactor showDiffPage
-        *
-        * @return boolean
-        */
-       public function isHiddenFromUser() {
-               if ( $this->isDeletedDiff() && ( !$this->unhide || 
!$this->isUserAllowedToSee() ) ) {
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
-       /**
-        * Returns warning messages in situations where a revision cannot be 
viewed by a user
-        * explaining to them why.
-        * Returns empty string when the revision can be viewed.
-        *
-        * @return string
-        */
-       public function getWarningMessageText() {
-               $msg = '';
-               if ( $this->isHiddenFromUser() ) {
-                       $allowed = $this->isUserAllowedToSee();
-                       $suppressed = $this->isSuppressedDiff();
-
-                       if ( !$allowed ) {
-                               $msg = $suppressed ? 'rev-suppressed-no-diff' : 
'rev-deleted-no-diff';
-                               $msg = wfMessage( $msg )->parse();
-                       } else {
-                               # Give explanation and add a link to view the 
diff...
-                               $query = $this->getRequest()->appendQueryValue( 
'unhide', '1', true );
-                               $link = $this->getTitle()->getFullURL( $query );
-                               $msg = $suppressed ? 
'rev-suppressed-unhide-diff' : 'rev-deleted-unhide-diff';
-                               $msg = wfMessage( $msg, $link )->parse();
-                       }
-               }
-               return $msg;
-       }
-
-       /**
         * Creates an inline diff
         * @param Content $otext Old content
         * @param Content $ntext New content
diff --git a/includes/specials/SpecialMobileDiff.php 
b/includes/specials/SpecialMobileDiff.php
index 4562ff0..802a813 100644
--- a/includes/specials/SpecialMobileDiff.php
+++ b/includes/specials/SpecialMobileDiff.php
@@ -9,8 +9,10 @@
        private $prevRev;
        /** @var Title */
        private $targetTitle;
-       /** @var boolean */
+       /** @var bool */
        private $useThanks = false;
+       /** @var bool */
+       private $unhide;
 
        public function __construct() {
                parent::__construct( 'MobileDiff' );
@@ -154,7 +156,7 @@
                $ctx = MobileContext::singleton();
 
                $prevId = $this->prevRev ? $this->prevRev->getId() : 0;
-               $unhide = (bool)$this->getRequest()->getVal( 'unhide' );
+               $this->unhide = (bool)$this->getRequest()->getVal( 'unhide' );
                $contentHandler = $this->rev->getContentHandler();
                $de = $contentHandler->createDifferenceEngine( 
$this->getContext(), $prevId, $this->revId );
                // HACK:
@@ -165,18 +167,18 @@
                                $this->revId,
                                0,
                                false,
-                               $unhide
+                               $this->unhide
                        );
                }
                $diff = $de->getDiffBody();
                if ( !$prevId ) {
-                       $audience = $unhide ? Revision::FOR_THIS_USER : 
Revision::FOR_PUBLIC;
+                       $audience = $this->unhide ? Revision::FOR_THIS_USER : 
Revision::FOR_PUBLIC;
                        $diff = '<ins>'
                                . nl2br( htmlspecialchars( $this->rev->getText( 
$audience ) ) )
                                . '</ins>';
                }
 
-               $warnings = $de->getWarningMessageText();
+               $warnings = $this->getWarningMessageText( $de );
                if ( $warnings ) {
                        $warnings = Html::openElement( 'div',
                                array(
@@ -212,6 +214,41 @@
                }
        }
 
+       /**
+        * Returns warning messages in situations where a revision cannot be 
viewed by a user
+        * explaining to them why.
+        * Returns empty string when the revision can be viewed.
+        *
+        * @param DifferenceEngine $de
+        * @return string
+        */
+       public function getWarningMessageText( DifferenceEngine $de ) {
+               $msg = '';
+               $deleted = $de->mNewRev && $de->mNewRev->isDeleted( 
Revision::DELETED_TEXT );
+               $suppressed = $deleted && $de->mNewRev->isDeleted( 
Revision::DELETED_RESTRICTED );
+               $user = $this->getUser();
+               $allowed = $de->mNewRev->userCan( Revision::DELETED_TEXT, $user 
);
+               if ( $de->mOldRev &&
+                       !$de->mOldRev->userCan( Revision::DELETED_TEXT, $user )
+               ) {
+                       $allowed = false;
+               }
+               $hidden = $deleted && ( !$this->unhide || !$allowed );
+               if ( $hidden ) {
+                       if ( !$allowed ) {
+                               $msg = $suppressed ? 'rev-suppressed-no-diff' : 
'rev-deleted-no-diff';
+                               $msg = wfMessage( $msg )->parse();
+                       } else {
+                               # Give explanation and add a link to view the 
diff...
+                               $query = $this->getRequest()->appendQueryValue( 
'unhide', '1', true );
+                               $link = $this->getPageTitle()->getFullURL( 
$query );
+                               $msg = $suppressed ? 
'rev-suppressed-unhide-diff' : 'rev-deleted-unhide-diff';
+                               $msg = wfMessage( $msg, $link )->parse();
+                       }
+               }
+               return $msg;
+       }
+
        function showFooter() {
                $output = $this->getOutput();
 

-- 
To view, visit https://gerrit.wikimedia.org/r/126880
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2bd07397c4185c4facb951fc0326f5ac6b0fe19
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <maxsem.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to