jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/357918 )

Change subject: Ensure mDiffEngine is always available
......................................................................


Ensure mDiffEngine is always available

The methods have been renamed to make it clearer what the purpose
of these methods are.

They are also made private to make it clear they should not be
used out of context.

addMobileDiff should only be called if InlineDifferenceEngine is
used as getWarningMessageText is not a method of DifferenceEngine

This is a follow up to
I68cf50f5dd339f34802d70df1f32d2c3390944a3

Bug: T167461
Change-Id: Ia59d76769960630859c9666acc5a28317e9272b7
---
M includes/specials/SpecialMobileDiff.php
1 file changed, 19 insertions(+), 16 deletions(-)

Approvals:
  Pmiazga: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/specials/SpecialMobileDiff.php 
b/includes/specials/SpecialMobileDiff.php
index e2c9b80..54fa5b6 100644
--- a/includes/specials/SpecialMobileDiff.php
+++ b/includes/specials/SpecialMobileDiff.php
@@ -134,9 +134,7 @@
 
                $output->addHtml( '<div id="mw-mf-diffview" 
class="content-unstyled"><div id="mw-mf-diffarea">' );
 
-               $this->setupDifferenceEngine();
-               $this->showHeader();
-               $this->showDiff();
+               $this->displayMobileDiff();
                $output->addHtml( '</div>' );
 
                $this->showFooter( $ctx );
@@ -156,15 +154,16 @@
        }
 
        /**
-        * Setups the DifferenceEngine.
+        * Setups the mobile DifferenceEngine and displays a mobile optimised 
diff.
         */
-       protected function setupDifferenceEngine() {
+       protected function displayMobileDiff() {
+               $useMobileMode = false;
                $contentHandler = $this->rev->getContentHandler();
-               $de = $contentHandler->createDifferenceEngine( 
$this->getContext(), $this->getPrevId(),
-                       $this->revId );
-               // HACK:
-               if ( get_class( $de ) == 'DifferenceEngine' ) {
-                       $de = new $this->diffClass(
+               $this->mDiffEngine = $contentHandler->createDifferenceEngine( 
$this->getContext(),
+                       $this->getPrevId(), $this->revId );
+
+               if ( get_class( $this->mDiffEngine ) == 'DifferenceEngine' ) {
+                       $this->mDiffEngine = new $this->diffClass(
                                $this->getContext(),
                                $this->getPrevId(),
                                $this->revId,
@@ -172,11 +171,15 @@
                                false,
                                (bool)$this->getRequest()->getVal( 'unhide' )
                        );
-               } else {
-                       $de->showDiffPage();
-                       return;
+                       $useMobileMode = true;
                }
-               $this->mDiffEngine = $de;
+
+               $this->showHeader();
+               if ( $useMobileMode ) {
+                       $this->addMobileDiff();
+               } else {
+                       $this->mDiffEngine->showDiffPage();
+               }
        }
 
        /**
@@ -186,7 +189,7 @@
         * Day and time of edit
         * Edit Comment
         */
-       function showHeader() {
+       private function showHeader() {
                $title = $this->targetTitle;
 
                if ( $this->prevRev ) {
@@ -259,7 +262,7 @@
         * Render the inline difference between two revisions
         * using InlineDiffEngine
         */
-       function showDiff() {
+       private function addMobileDiff() {
                $output = $this->getOutput();
 
                $prevId = $this->getPrevId();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia59d76769960630859c9666acc5a28317e9272b7
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Pmiazga <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to