Allow hooks to abort lines in EnhancedRC
authorMatthias Mullie <git@mullie.eu>
Thu, 2 Jul 2015 12:32:50 +0000 (14:32 +0200)
committerMatthias Mullie <git@mullie.eu>
Fri, 3 Jul 2015 08:18:58 +0000 (10:18 +0200)
Bug: T104564
Change-Id: I4a2f97d83f38071984d571773a6b09b6b6643d6d

docs/hooks.txt
includes/changes/EnhancedChangesList.php

index 92bc95a..23df983 100644 (file)
@@ -1300,12 +1300,14 @@ $editToken: The user's edit token.
 
 'EnhancedChangesList::getLogText': to alter, remove or add to the links of a
 group of changes in EnhancedChangesList.
+Hook subscribers can return false to omit this line from recentchanges.
 $changesList: EnhancedChangesList object
 &$links: The links that were generated by EnhancedChangesList
 $block: The RecentChanges objects in that block
 
 'EnhancedChangesListModifyLineData': to alter data used to build
 a grouped recent change inner line in EnhancedChangesList.
+Hook subscribers can return false to omit this line from recentchanges.
 $changesList: EnhancedChangesList object
 &$data: An array with all the components that will be joined in order to create the line
 $block: An array of RecentChange objects in that block
index fe7deb6..9635c17 100644 (file)
@@ -378,8 +378,12 @@ class EnhancedChangesList extends ChangesList {
                        $data['tags'] = $this->getTags( $rcObj, $classes );
 
                        // give the hook a chance to modify the data
-                       Hooks::run( 'EnhancedChangesListModifyLineData',
+                       $success = Hooks::run( 'EnhancedChangesListModifyLineData',
                                array( $this, &$data, $block, $rcObj ) );
+                       if ( !$success ) {
+                               // skip entry if hook aborted it
+                               continue;
+                       }
 
                        $line = '<tr' . $trClass . '><td></td><td class="mw-enhanced-rc">';
                        if ( isset( $data['recentChangesFlags'] ) ) {
@@ -599,8 +603,12 @@ class EnhancedChangesList extends ChangesList {
                $data['watchingUsers'] = $this->numberofWatchingusers( $rcObj->numberofWatchingusers );
 
                // give the hook a chance to modify the data
-               Hooks::run( 'EnhancedChangesListModifyBlockLineData',
+               $success = Hooks::run( 'EnhancedChangesListModifyBlockLineData',
                        array( $this, &$data, $rcObj ) );
+               if ( !$success ) {
+                       // skip entry if hook aborted it
+                       return '';
+               }
 
                $line = Html::openElement( 'table', array( 'class' => $classes ) ) .
                        Html::openElement( 'tr' );