From: aude Date: Fri, 9 Nov 2012 16:17:48 +0000 (+0000) Subject: allow OldChangesListRecentChangesLine hook to return false and omit line from RC X-Git-Tag: 1.31.0-rc.0~21206^2 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=e6a811b4366b298f4d56876ed65b66cbf9ccf0c2;p=lhc%2Fweb%2Fwiklou.git allow OldChangesListRecentChangesLine hook to return false and omit line from RC - this enables an extension to do some processing on the RC line, and if processing fails or for other reason, the extension has the option to not output the line at all in Special:RecentChanges and Special:Watchlist. Change-Id: Ibf3a217afba5b4ad7992919399710fe3da301025 --- diff --git a/docs/hooks.txt b/docs/hooks.txt index 701c312554..994c08c431 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1522,7 +1522,8 @@ displayed &$transform: whether or not to expand variables and templates in the message (bool) -'OldChangesListRecentChangesLine': Customize entire Recent Changes line. +'OldChangesListRecentChangesLine': Customize entire Recent Changes line, +or return false to omit the line from RecentChanges and Watchlist special pages. &$changeslist: The OldChangesList instance. &$s: HTML of the form "
  • ...
  • " containing one RC entry. &$rc: The RecentChange object. diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 1d2f362f5e..92cdeea8eb 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -590,7 +590,8 @@ class OldChangesList extends ChangesList { * @param $rc RecentChange, passed by reference * @param $watched Bool (default false) * @param $linenumber Int (default null) - * @return string + * + * @return string|bool */ public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) { global $wgRCShowChangedSize; @@ -681,7 +682,10 @@ class OldChangesList extends ChangesList { $classes[] = Sanitizer::escapeClass( 'watchlist-'.$rc->mAttribs['rc_namespace'].'-'.$rc->mAttribs['rc_title'] ); } - wfRunHooks( 'OldChangesListRecentChangesLine', array(&$this, &$s, $rc) ); + if ( !wfRunHooks( 'OldChangesListRecentChangesLine', array( &$this, &$s, $rc ) ) ) { + wfProfileOut( __METHOD__ ); + return false; + } wfProfileOut( __METHOD__ ); return "$dateheader
  • ".$s."
  • \n"; diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 2984bc7595..39776735c0 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -529,8 +529,12 @@ class SpecialRecentChanges extends IncludableSpecialPage { } $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title]; } - $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter ); - --$limit; + + $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter ); + if ( $changeLine !== false ) { + $s .= $changeLine; + --$limit; + } } $s .= $list->endRecentChangesList(); $this->getOutput()->addHTML( $s ); diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 688e0a50cb..3cfa31f167 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -432,7 +432,10 @@ class SpecialWatchlist extends SpecialPage { $rc->numberofWatchingusers = 0; } - $s .= $list->recentChangesLine( $rc, $updated, $counter ); + $changeLine = $list->recentChangesLine( $rc, $updated, $counter ); + if ( $changeLine !== false ) { + $s .= $changeLine; + } } $s .= $list->endRecentChangesList();