Chad has uploaded a new change for review.

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

Change subject: Revert "Make APIEditBeforeSave give the whole revision"
......................................................................

Revert "Make APIEditBeforeSave give the whole revision"

This may negatively affect performance and the whole purpose of the
hook (making it possible to reject an edit from an extension while
providing detailed error information in the API result) has been
invalidated by 09a5febb7b024c0b6585141bb05cba13a642f3eb, which lets
EditFilterMergedContent do this too.

I think it was intentional that the hook was called with just the text
passed to action=edit API. Making it actually be called with the text
that's going to be saved would require more work (e.g. for
automatically resolved edit conflicts, T73947).

Very few extensions use this hook. I'm fixing AbuseFilter to use
EditFilterMergedContent in I30c1e3d0a6c10888e6ac53745313434474663cce,
we should also review ConfirmEdit, ProofreadPage and SpamBlacklist to
see what behavior they really expect.

This reverts commit be97167ab61e7d59d86f6a9dca53b7016d615735.

Change-Id: I62713419496bcf57364a8fa9de93c0c8ddc3e91c
(cherry picked from commit 070783d314205b00e94256b2ef47dfab77a36118)
---
M RELEASE-NOTES-1.27
M docs/hooks.txt
M includes/api/ApiEditPage.php
3 files changed, 8 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/79/293879/1

diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27
index 6c253f3..79455cb 100644
--- a/RELEASE-NOTES-1.27
+++ b/RELEASE-NOTES-1.27
@@ -261,6 +261,9 @@
 === Bug fixes in 1.27 ===
 * Special:Upload will now display correct maximum allowed file size when 
running
   under HHVM (T116347).
+* (T54077) The APIEditBeforeSave hook will once again give only the content of
+  the section being edited, rather than the whole revision. This reverts the
+  change made in MediaWiki 1.22.
 
 === Action API changes in 1.27 ===
 * Added list=allrevisions.
diff --git a/docs/hooks.txt b/docs/hooks.txt
index 032caba..3a1ab1a 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -375,8 +375,12 @@
 processing request parameters. Return false to let the request fail, returning
 an error message or an <edit result="Failure"> tag if $resultArr was filled.
 Unlike for example 'EditFilterMergedContent' this also being run on undo.
+Since MediaWiki 1.25, 'EditFilterMergedContent' can also return error details
+for the API and it's recommended to use it instead of this hook.
 $editPage: the EditPage object
-$text: the new text of the article (has yet to be saved)
+$text: the text passed to the API. Note that this includes only the single
+  section for section edit, and is not necessarily the final text in case of
+  automatically resolved edit conflicts.
 &$resultArr: data in this array will be added to the API result
 
 'ApiFeedContributions::feedItem': Called to convert the result of ContribsPager
diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php
index 08aba94..d3d7a4d 100644
--- a/includes/api/ApiEditPage.php
+++ b/includes/api/ApiEditPage.php
@@ -398,35 +398,6 @@
                $ep->importFormData( $req );
                $content = $ep->textbox1;
 
-               // The following is needed to give the hook the full content of 
the
-               // new revision rather than just the current section. (Bug 
52077)
-               if ( !is_null( $params['section'] ) &&
-                       $contentHandler->supportsSections() && 
$titleObj->exists()
-               ) {
-                       // If sectiontitle is set, use it, otherwise use the 
summary as the section title (for
-                       // backwards compatibility with old forms/bots).
-                       if ( $ep->sectiontitle !== '' ) {
-                               $sectionTitle = $ep->sectiontitle;
-                       } else {
-                               $sectionTitle = $ep->summary;
-                       }
-
-                       $contentObj = $contentHandler->unserializeContent( 
$content, $contentFormat );
-
-                       $fullContentObj = $articleObject->replaceSectionContent(
-                               $params['section'],
-                               $contentObj,
-                               $sectionTitle
-                       );
-                       if ( $fullContentObj ) {
-                               $content = $fullContentObj->serialize( 
$contentFormat );
-                       } else {
-                               // This most likely means we have an edit 
conflict which means that the edit
-                               // wont succeed anyway.
-                               $this->dieUsageMsg( 'editconflict' );
-                       }
-               }
-
                // Run hooks
                // Handle APIEditBeforeSave parameters
                $r = [];

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I62713419496bcf57364a8fa9de93c0c8ddc3e91c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_27
Gerrit-Owner: Chad <ch...@wikimedia.org>
Gerrit-Reviewer: Bartosz DziewoƄski <matma....@gmail.com>

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

Reply via email to