Special:ChangeContentModel: Run EditFilterMergedContent hook
authorKunal Mehta <legoktm@member.fsf.org>
Tue, 13 Sep 2016 08:10:35 +0000 (01:10 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Wed, 14 Sep 2016 00:06:46 +0000 (17:06 -0700)
This will allow tools like AbuseFilter to filter changes made through
the special page, and matches the EditPage behavior that already runs
this hook.

Bug: T145489
Change-Id: I3204e3a228af2cdd4e2ab4e8c760cc126a8e1947

includes/specials/SpecialChangeContentModel.php

index b37c475..dd7f0ed 100644 (file)
@@ -221,6 +221,22 @@ class SpecialChangeContentModel extends FormSpecialPage {
                # Truncate for whole multibyte characters.
                $reason = $wgContLang->truncate( $reason, 255 );
 
+               // Run edit filters
+               $derivativeContext = new DerivativeContext( $this->getContext() );
+               $derivativeContext->setTitle( $this->title );
+               $derivativeContext->setWikiPage( $page );
+               $status = new Status();
+               if ( !Hooks::run( 'EditFilterMergedContent',
+                               [ $derivativeContext, $newContent, $status, $reason,
+                               $user, false ] )
+               ) {
+                       if ( $status->isGood() ) {
+                               // TODO: extensions should really specify an error message
+                               $status->fatal( 'hookaborted' );
+                       }
+                       return $status;
+               }
+
                $status = $page->doEditContent(
                        $newContent,
                        $reason,