Jdlrobson has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/357918 )
Change subject: Ensure mDiffEngine is available inside showDiff
......................................................................
Ensure mDiffEngine is available inside showDiff
To be defensive against this in future a RuntimeException is now
thrown.
The methods have been renamed to make it clearer what the purpose
of these methods are.
addMobileDiff should only be called if InlineDifferenceEngine is
used as getWarningMessageText is not a method of DifferenceEngine
Bug: T167461
Change-Id: Ia59d76769960630859c9666acc5a28317e9272b7
---
M includes/specials/SpecialMobileDiff.php
1 file changed, 13 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/18/357918/1
diff --git a/includes/specials/SpecialMobileDiff.php
b/includes/specials/SpecialMobileDiff.php
index e2c9b80..8eb89af 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,12 +154,14 @@
}
/**
- * Setups the DifferenceEngine.
+ * Setups the mobile DifferenceEngine and displays a mobile optimised
diff.
*/
- protected function setupDifferenceEngine() {
+ protected function displayMobileDiff() {
+ $this->showHeader();
$contentHandler = $this->rev->getContentHandler();
$de = $contentHandler->createDifferenceEngine(
$this->getContext(), $this->getPrevId(),
$this->revId );
+
// HACK:
if ( get_class( $de ) == 'DifferenceEngine' ) {
$de = new $this->diffClass(
@@ -172,11 +172,11 @@
false,
(bool)$this->getRequest()->getVal( 'unhide' )
);
+ $this->mDiffEngine = $de;
+ $this->addMobileDiff();
} else {
$de->showDiffPage();
- return;
}
- $this->mDiffEngine = $de;
}
/**
@@ -259,12 +259,17 @@
* Render the inline difference between two revisions
* using InlineDiffEngine
*/
- function showDiff() {
+ private function addMobileDiff() {
$output = $this->getOutput();
$prevId = $this->getPrevId();
$unhide = (bool)$this->getRequest()->getVal( 'unhide' );
$de = $this->mDiffEngine;
+ // This must always be available! (T167461)
+ if ( !$de ) {
+ throw new \RuntimeException(
+ "addMobileDiff was called on an incompatible
diff engine." );
+ }
$diff = $de->getDiffBody();
if ( !$prevId ) {
$audience = $unhide ? Revision::FOR_THIS_USER :
Revision::FOR_PUBLIC;
--
To view, visit https://gerrit.wikimedia.org/r/357918
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia59d76769960630859c9666acc5a28317e9272b7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits