Catch when no changes are actually saved when posting a comment

Bug: T268069
Change-Id: Ib9c136d846668335884a242322d5b0d4e038c6b1
This commit is contained in:
Bartosz Dziewoński 2020-11-18 20:40:05 +01:00 committed by Esanders
parent 7ada28e361
commit 1c8ca53c92
4 changed files with 10 additions and 0 deletions

View file

@ -80,6 +80,7 @@
"discussiontools-postedit-confirmation-published",
"discussiontools-error-comment-conflict",
"discussiontools-error-comment-disappeared",
"discussiontools-error-comment-not-saved",
"discussiontools-error-comment-is-transcluded",
"discussiontools-error-comment-is-transcluded-title",
"discussiontools-error-lint",

View file

@ -44,6 +44,7 @@
"discussiontools-signature-prefix": " ",
"discussiontools-error-comment-conflict": "Your comment could not be saved, because someone else commented at the same time as you. Please try again, or reload the page to view the latest comments.",
"discussiontools-error-comment-disappeared": "Could not find the comment you're replying to on the page. It might have been deleted or moved to another page. Please reload the page and try again.",
"discussiontools-error-comment-not-saved": "Your comment could not be saved in the latest version of the page. Please reload the page to see the latest changes.",
"discussiontools-error-comment-is-transcluded": "The \"{{int:discussiontools-replylink}}\" link cannot be used to reply to this comment. To reply, please use the full page editor by clicking \"$1\".",
"discussiontools-error-comment-is-transcluded-title": "The \"{{int:discussiontools-replylink}}\" link cannot be used to reply to this comment because it is loaded from another page. To reply, please go here: [[$1]].",
"discussiontools-error-lint": "Comments on this page can't be replied to because of an error in the wikitext. You can learn about this error by [$1 reading the documentation], ask for help by [$2 posting here] or fix the error by [$3 opening the full page editor].",

View file

@ -51,6 +51,7 @@
"discussiontools-signature-prefix": "{{optional}}\nWikitext that prefixes the signature. The prefix and signature will be appended directly to the message, so this must include a leading space if a gap is desired.\n\nThis message intentionally doesn't use the prefix from {{msg-mw|sig-text}}, because it is not actually commonly used on many wikis, but you can include it in the translation if that is the convention in your language.\n{{Format|plain}}",
"discussiontools-error-comment-conflict": "Error message of a comment conflict.\n\nSimilar messages:\n* {{msg-mw|visualeditor-editconflict}}\n* {{msg-mw|twocolconflict-split-tour-dialog-message-single-column-view}}\n* {{msg-mw|discussiontools-error-comment-disappeared}}",
"discussiontools-error-comment-disappeared": "Error message.",
"discussiontools-error-comment-not-saved": "Error message.",
"discussiontools-error-comment-is-transcluded": "Error message. Parameter: $1 text of the 'Edit'/'Edit source' tab",
"discussiontools-error-comment-is-transcluded-title": "Error message. Parameter: $1 page name",
"discussiontools-error-lint": "Error message. Parameters:\n* $1 URL to documentation on mediawiki.org\n* $2 URL to talk page on mediawiki.org\n* $3 URL to the editor (action=edit)",

View file

@ -197,6 +197,13 @@ class ApiDiscussionToolsEdit extends ApiBase {
break;
}
if ( !isset( $result['newrevid'] ) ) {
// No new revision, so no changes were made to the page (null edit).
// Comment was not actually saved, so for this API, that's an error.
// This is probably because changes were inside a transclusion's HTML?
$this->dieWithError( 'discussiontools-error-comment-not-saved', 'comment-comment-not-saved' );
}
$this->getResult()->addValue( null, $this->getModuleName(), $result );
}