Catrope has uploaded a new change for review.

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


Change subject: Output a nice message when the diff is empty
......................................................................

Output a nice message when the diff is empty

Bug: 43754
Change-Id: I8daae124b060ccf54ce5ca7c1e1a6d18b7265ade
---
M ApiVisualEditor.php
M VisualEditor.i18n.php
2 files changed, 13 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/36/63236/1

diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php
index d4eb318..c218f13 100644
--- a/ApiVisualEditor.php
+++ b/ApiVisualEditor.php
@@ -164,14 +164,18 @@
                }
                $diffRows = 
$result['query']['pages'][$title->getArticleID()]['revisions'][0]['diff']['*'];
 
-               $context = new DerivativeContext( $this->getContext() );
-               $context->setTitle( $title );
-               $engine = new DifferenceEngine( $context );
-               return $engine->addHeader(
-                       $diffRows,
-                       wfMessage( 'currentrev' )->parse(),
-                       wfMessage( 'yourtext' )->parse()
-               );
+               if ( $diffRows !== '' ) {
+                       $context = new DerivativeContext( $this->getContext() );
+                       $context->setTitle( $title );
+                       $engine = new DifferenceEngine( $context );
+                       return $engine->addHeader(
+                               $diffRows,
+                               wfMessage( 'currentrev' )->parse(),
+                               wfMessage( 'yourtext' )->parse()
+                       );
+               } else {
+                       return wfMessage( 'visualeditor-diff-nochanges' 
)->parse();
+               }
        }
 
        public function execute() {
diff --git a/VisualEditor.i18n.php b/VisualEditor.i18n.php
index 38e418d..3da9b76 100644
--- a/VisualEditor.i18n.php
+++ b/VisualEditor.i18n.php
@@ -84,6 +84,7 @@
        'visualeditor-report-notice' => 'I understand that by clicking "Report 
problem" I will transmit my changes and my feedback, which will be stored for 
analysis. I agree to provide feedback in accordance with the 
[[{{MediaWiki:Visualeditor-report-link}}|Terms of Use]].',
        'visualeditor-report-link' => 'foundation:Terms of Use',
        'visualeditor-feedback-link' => 'Project:VisualEditor/Feedback',
+       'visualeditor-diff-nochanges' => 'Your edit will be ignored because you 
have made no changes to the text.',
 );
 
 /** Message documentation (Message documentation)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8daae124b060ccf54ce5ca7c1e1a6d18b7265ade
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

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

Reply via email to