jenkins-bot has submitted this change and it was merged.

Change subject: Display 'editingold' as a notice when editing old version of a 
page
......................................................................


Display 'editingold' as a notice when editing old version of a page

Bug: 47683
Change-Id: I216cdd68014173aa65cad42ddd3d870334be9ead
---
M ApiVisualEditor.php
1 file changed, 15 insertions(+), 4 deletions(-)

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



diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php
index 63ebe33..941190d 100644
--- a/ApiVisualEditor.php
+++ b/ApiVisualEditor.php
@@ -12,6 +12,9 @@
        protected function getHTML( $title, $parserParams ) {
                global $wgVisualEditorParsoidURL, $wgVisualEditorParsoidPrefix,
                        $wgVisualEditorParsoidTimeout;
+
+               $restoring = false;
+
                if ( $title->exists() ) {
                        if ( $parserParams['oldid'] === 0 ) {
                                $parserParams['oldid'] = ''; // Parsoid wants 
empty string rather than zero
@@ -20,6 +23,8 @@
                        if ( $revision === null ) {
                                return false;
                        }
+                       $restoring = !$revision->isCurrent();
+
                        $parserParams['touched'] = $title->getTouched();
                        $parserParams['cache'] = 1;
 
@@ -59,9 +64,12 @@
                        $timestamp = wfTimestampNow();
                }
                return array(
-                       'content' => $content,
-                       'basetimestamp' => $timestamp,
-                       'starttimestamp' => wfTimestampNow()
+                       'result' => array(
+                               'content' => $content,
+                               'basetimestamp' => $timestamp,
+                               'starttimestamp' => wfTimestampNow(),
+                       ),
+                       'restoring' => $restoring,
                );
        }
 
@@ -232,6 +240,9 @@
                                if ( $user->isAnon() ) {
                                        $wgVisualEditorEditNotices[] = 
'anoneditwarning';
                                }
+                               if ( $parsed && $parsed['restoring'] ) {
+                                       $wgVisualEditorEditNotices[] = 
'editingold';
+                               }
                                if ( count( $wgVisualEditorEditNotices ) ) {
                                        foreach ( $wgVisualEditorEditNotices as 
$key ) {
                                                $notices[] = wfMessage( $key 
)->parseAsBlock();
@@ -241,7 +252,7 @@
                                        $this->dieUsage( 'Error contacting the 
Parsoid server', 'parsoidserver' );
                                } else {
                                        $result = array_merge(
-                                               array( 'result' => 'success', 
'notices' => $notices ), $parsed
+                                               array( 'result' => 'success', 
'notices' => $notices ), $parsed['result']
                                        );
                                }
                                break;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I216cdd68014173aa65cad42ddd3d870334be9ead
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>
Gerrit-Reviewer: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to