Gerrit Patch Uploader has uploaded a new change for review. https://gerrit.wikimedia.org/r/230304
Change subject: Inform author of successful edit conflict resolution ...................................................................... Inform author of successful edit conflict resolution Use the post edit notification to inform the author when an edit conflict occurred which was automatically resolved. Bug: T76997 Change-Id: I623b050e1b622e2982d835573ec2183c24187e8f --- M includes/EditPage.php M languages/i18n/en.json M languages/i18n/qqq.json M resources/Resources.php M resources/src/mediawiki.action/mediawiki.action.view.postEdit.js 5 files changed, 30 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/04/230304/1 diff --git a/includes/EditPage.php b/includes/EditPage.php index 0ca2f80..82417be 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1290,17 +1290,28 @@ * since the post-edit state should only apply to the load right after the save. * * @param int $statusValue The status value (to check for new article status) + * @param array $resultDetails The resultDetails (to check for null edits and + * edit conflicts) */ - protected function setPostEditCookie( $statusValue ) { + protected function setPostEditCookie( $statusValue, $resultDetails ) { + $val = false; + if ( !$resultDetails['nullEdit'] ) { + $val = 'saved'; + if ( $resultDetails['editConflictResolved'] ) { + $val = 'resolved'; + } elseif ( $statusValue == self::AS_SUCCESS_NEW_ARTICLE ) { + $val = 'created'; + } elseif ( $this->oldid ) { + $val = 'restored'; + } + } + + if ( !$val ) { + return; + } + $revisionId = $this->mArticle->getLatest(); $postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId; - - $val = 'saved'; - if ( $statusValue == self::AS_SUCCESS_NEW_ARTICLE ) { - $val = 'created'; - } elseif ( $this->oldid ) { - $val = 'restored'; - } $response = RequestContext::getMain()->getRequest()->response(); $response->setcookie( $postEditKey, $val, time() + self::POST_EDIT_COOKIE_DURATION, array( @@ -1346,9 +1357,7 @@ || $status->value == self::AS_SUCCESS_NEW_ARTICLE ) { $this->didSave = true; - if ( !$resultDetails['nullEdit'] ) { - $this->setPostEditCookie( $status->value ); - } + $this->setPostEditCookie( $status->value, $resultDetails ); } switch ( $status->value ) { @@ -1536,6 +1545,8 @@ * false otherwise. * - redirect (bool): Set if doEditContent is OK. True if resulting * revision is a redirect. + * - editConflictResolved (boolean): Set if doEditContent is OK. True if + * an edit conflict was resolved, false otherwise. * @param bool $bot True if edit is being made under the bot right. * * @return Status Status object, possibly with a message, but always with @@ -1717,6 +1728,7 @@ # we detect it by using page_latest like a token in a 1 try compare-and-swap. $this->mArticle->loadPageData( 'fromdbmaster' ); $new = !$this->mArticle->exists(); + $editConflictResolved = false; if ( $new ) { // Late check for create permission, just in case *PARANOIA* @@ -1837,8 +1849,9 @@ } elseif ( $this->isConflict ) { # Attempt merge if ( $this->mergeChangesIntoContent( $content ) ) { - // Successful merge! Maybe we should tell the user the good news? + // Successful merge! Remember it, so we can tell the user the good news. $this->isConflict = false; + $editConflictResolved = true; wfDebug( __METHOD__ . ": Suppressing edit conflict, successful merge.\n" ); } else { $this->section = ''; @@ -1968,6 +1981,7 @@ $wgUser->pingLimiter( 'linkpurge' ); } $result['redirect'] = $content->isRedirect(); + $result['editConflictResolved'] = $editConflictResolved; $this->updateWatchlist(); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 2633edd..2393b40 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -696,6 +696,7 @@ "edit-conflict": "Edit conflict.", "edit-no-change": "Your edit was ignored because no change was made to the text.", "postedit-confirmation-created": "The page has been created.", + "postedit-confirmation-resolved": "Another user saved the page while you edited it, but your edit was saved, too.", "postedit-confirmation-restored": "The page has been restored.", "postedit-confirmation-saved": "Your edit was saved.", "edit-already-exists": "Could not create a new page.\nIt already exists.", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 17f1c46..4588397 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -867,6 +867,7 @@ "edit-conflict": "An 'Edit conflict' happens when more than one edit is being made to a page at the same time. This would usually be caused by separate individuals working on the same page. However, if the system is slow, several edits from one individual could back up and attempt to apply simultaneously - causing the conflict.\n\nSee also:\n* {{msg-mw|edit-hook-aborted}}\n* {{msg-mw|edit-gone-missing}}\n* {{msg-mw|edit-no-change}}\n* {{msg-mw|edit-already-exists}}", "edit-no-change": "Used as error message.\n\nSee also:\n* {{msg-mw|edit-hook-aborted}}\n* {{msg-mw|edit-gone-missing}}\n* {{msg-mw|edit-conflict}}\n* {{msg-mw|edit-already-exists}}", "postedit-confirmation-created": "{{gender}}\nShown after a user creates a new page. Parameters:\n* $1 - the current user, for GENDER support", + "postedit-confirmation-resolved": "{{gender}}\nShown after a user saves a page, after an edit conflict was resolved automatically. Parameters:\n* $1 - the current user, for GENDER support", "postedit-confirmation-restored": "{{gender}}\nShown after a user restores a page to a previous revision. Parameters:\n* $1 - the current user, for GENDER support", "postedit-confirmation-saved": "{{gender}}\nShown after a user saves a page. Parameters:\n* $1 - the current user, for GENDER support", "edit-already-exists": "Used as error message.\n\nSee also:\n* {{msg-mw|edit-hook-aborted}}\n* {{msg-mw|edit-gone-missing}}\n* {{msg-mw|edit-conflict}}\n* {{msg-mw|edit-no-change}}", diff --git a/resources/Resources.php b/resources/Resources.php index 2396128..fa2bab8 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1264,6 +1264,7 @@ ), 'messages' => array( 'postedit-confirmation-created', + 'postedit-confirmation-resolved', 'postedit-confirmation-restored', 'postedit-confirmation-saved', ), diff --git a/resources/src/mediawiki.action/mediawiki.action.view.postEdit.js b/resources/src/mediawiki.action/mediawiki.action.view.postEdit.js index c008dfd..46dc276 100644 --- a/resources/src/mediawiki.action/mediawiki.action.view.postEdit.js +++ b/resources/src/mediawiki.action/mediawiki.action.view.postEdit.js @@ -68,6 +68,7 @@ // postedit-confirmation-saved // postedit-confirmation-created // postedit-confirmation-restored + // postEdit-confirmation-resolved 'message': mw.msg( 'postedit-confirmation-' + cookieVal, mw.user -- To view, visit https://gerrit.wikimedia.org/r/230304 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I623b050e1b622e2982d835573ec2183c24187e8f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Schnark <listenle...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits