Use $user param when filtering edits

This can be different from the User set inside the $context object, as
seen e.g. in Wikibase jobs. Given that the hook provides a $user param,
it makes more sense to use that, rather than extracting it from the
ContextSource kitchen sink.

Bug: T258717
Change-Id: Ib5961068d3df6ae2bfc3f9c6a7b9e555d248b332
This commit is contained in:
Daimona Eaytoy 2020-08-19 14:24:57 +02:00
parent cb9ed4a957
commit 28ea0e525a

View file

@ -107,7 +107,7 @@ class AbuseFilterHooks {
) {
$startTime = microtime( true );
$filterResult = self::filterEdit( $context, $content, $summary, $slot );
$filterResult = self::filterEdit( $context, $user, $content, $summary, $slot );
if ( !$filterResult->isOK() ) {
// Produce a useful error message for API edits
@ -122,12 +122,16 @@ class AbuseFilterHooks {
* Implementation for EditFilterMergedContent hook.
*
* @param IContextSource $context the context of the edit
* @param User $user
* @param Content $content the new Content generated by the edit
* @param string $summary Edit summary for page
* @param string $slot slot role for the content
* @return Status
*/
public static function filterEdit( IContextSource $context, Content $content,
public static function filterEdit(
IContextSource $context,
User $user,
Content $content,
$summary, $slot = SlotRecord::MAIN
) : Status {
self::$lastEditPage = null;
@ -143,7 +147,6 @@ class AbuseFilterHooks {
return Status::newGood();
}
$user = $context->getUser();
if ( $title->canExist() && $title->exists() ) {
// Make sure we load the latest text saved in database (bug 31656)
$page = $context->getWikiPage();