X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFeedContributions.php;h=edda67231f5adaab45579104e2887d151fdc3f94;hb=524d92b61f2a951200b00326cfac6b25a830acb6;hp=ced5f0c24932f67ca640e47ea8d996e82f99975c;hpb=885a8bdc47e6f5b9add4d5ddcb9c63a2d95e3a70;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php index ced5f0c249..edda67231f 100644 --- a/includes/api/ApiFeedContributions.php +++ b/includes/api/ApiFeedContributions.php @@ -95,7 +95,10 @@ class ApiFeedContributions extends ApiBase { if ( ++$count > $limit ) { break; } - $feedItems[] = $this->feedItem( $row ); + $item = $this->feedItem( $row ); + if ( $item !== null ) { + $feedItems[] = $item; + } } } @@ -103,6 +106,23 @@ class ApiFeedContributions extends ApiBase { } protected function feedItem( $row ) { + // This hook is the api contributions equivalent to the + // ContributionsLineEnding hook. Hook implementers may cancel + // the hook to signal the user is not allowed to read this item. + $feedItem = null; + $hookResult = Hooks::run( + 'ApiFeedContributions::feedItem', + array( $row, $this->getContext(), &$feedItem ) + ); + // Hook returned a valid feed item + if ( $feedItem instanceof FeedItem ) { + return $feedItem; + // Hook was canceled and did not return a valid feed item + } elseif ( !$hookResult ) { + return null; + } + + // Hook completed and did not return a valid feed item $title = Title::makeTitle( intval( $row->page_namespace ), $row->page_title ); if ( $title && $title->userCan( 'read', $this->getUser() ) ) { $date = $row->rev_timestamp;