Remove backwards-compatibility code using APIEditBeforeSave hook

It was only needed for MediaWiki prior to 1.25
(09a5febb7b024c0b6585141bb05cba13a642f3eb).
We no longer support those versions after
d527574d2b.

Bug: T137832
Change-Id: I9d0b7e7713c805ebc7bf59f55456e69c6491e265
This commit is contained in:
Bartosz Dziewoński 2016-06-16 17:40:36 +02:00
parent 063ac925a8
commit c03ac953ad
2 changed files with 4 additions and 56 deletions

View file

@ -34,50 +34,6 @@ class AbuseFilterHooks {
}
}
/**
* Entry point for the APIEditBeforeSave hook.
*
* This is needed to give a useful error for API edits on MediaWiki before 1.25 (T34216).
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/APIEditBeforeSave
*
* @param EditPage $editPage
* @param string $text New text of the article (has yet to be saved)
* @param array &$result Data in this array will be added to the API result
*
* @return bool
*/
public static function onAPIEditBeforeSave( $editPage, $text, &$result ) {
// Don't use the APIEditBeforeSave hook if EditFilterMergedContent allows us to produce error
// details for the API, it lies in case of autoresolved edit conflicts (T73947).
if ( defined( 'MW_EDITFILTERMERGED_SUPPORTS_API' ) ) {
return true;
}
if ( $editPage->undidRev > 0 ) {
// This hook is also (unlike the non-API hooks) being run on undo,
// but we don't want to filter in that case. T126861
return true;
}
$context = $editPage->mArticle->getContext();
$status = Status::newGood();
$minoredit = $editPage->minoredit;
$summary = $editPage->summary;
// poor man's PST, see bug 20310
$text = str_replace( "\r\n", "\n", $text );
self::filterEdit( $context, null, $text, $status, $summary, $minoredit );
if ( !$status->isOK() ) {
$result = self::getEditApiResult( $status );
}
return $status->isOK();
}
/**
* Entry point for the EditFilterMergedContent hook.
*
@ -97,8 +53,8 @@ class AbuseFilterHooks {
$continue = self::filterEdit( $context, $content, $text, $status, $summary, $minoredit );
if ( defined( 'MW_EDITFILTERMERGED_SUPPORTS_API' ) && !$status->isOK() ) {
// Produce a useful error message for API edits (T34216) without APIEditBeforeSave (T73947)
if ( !$status->isOK() ) {
// Produce a useful error message for API edits
$status->apiHookResult = self::getEditApiResult( $status );
}
@ -106,7 +62,7 @@ class AbuseFilterHooks {
}
/**
* Common implementation for the APIEditBeforeSave and EditFilterMergedContent hooks.
* Implementation for EditFilterMergedContent hook.
*
* @param IContextSource $context the context of the edit
* @param Content|null $content the new Content generated by the edit
@ -122,13 +78,6 @@ class AbuseFilterHooks {
$title = $context->getTitle();
// Some edits are running through multiple hooks, but we only want to filter them once
if ( isset( $title->editAlreadyFiltered ) ) {
return true;
} elseif ( $title ) {
$title->editAlreadyFiltered = true;
}
self::$successful_action_vars = false;
self::$last_edit_page = false;
@ -212,7 +161,7 @@ class AbuseFilterHooks {
}
/**
* Common implementation for the APIEditBeforeSave and EditFilterMergedContent hooks.
* Implementation for EditFilterMergedContent hook.
*
* @param Status $status Error message details
* @return array API result

View file

@ -181,7 +181,6 @@
"UploadVerifyFile": "AbuseFilterHooks::onUploadVerifyFile",
"MakeGlobalVariablesScript": "AbuseFilterHooks::onMakeGlobalVariablesScript",
"ArticleSaveComplete": "AbuseFilterHooks::onArticleSaveComplete",
"APIEditBeforeSave": "AbuseFilterHooks::onAPIEditBeforeSave",
"UserMergeAccountFields": "AbuseFilterHooks::onUserMergeAccountFields",
"ParserOutputStashForEdit": "AbuseFilterHooks::onParserOutputStashForEdit",
"UnitTestsList": "AbuseFilterHooks::onUnitTestsList"