From dc3ddcc4a2b5ac55a2e2a5416b496f129412640e Mon Sep 17 00:00:00 2001 From: Matthias Mullie Date: Thu, 2 Jul 2015 14:32:50 +0200 Subject: [PATCH] Allow hooks to abort lines in EnhancedRC Bug: T104564 Change-Id: I4a2f97d83f38071984d571773a6b09b6b6643d6d --- docs/hooks.txt | 2 ++ includes/changes/EnhancedChangesList.php | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 92bc95a098..23df983240 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index fe7deb60dd..9635c1791d 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -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 = ''; 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' ); -- 2.20.1