EBernhardson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/185062

Change subject: Introduce ApiFeedContributions::feedItem hook
......................................................................

Introduce ApiFeedContributions::feedItem hook

ContribsPager, which is used by ApiFeedContributions, can return more
than just revision rows.  This is handled in the html side within the
ContributionsLineEnding hook.  ApiFeedContributions had no special
handling so here I have added a simple hook the provides the data
from ContribsPager and allows subscribers to provide the appropriate
FeedItem instance.

Bug: T85229
Change-Id: I27c77cc682ba801c40361c76b67398108ca1a592
---
M docs/hooks.txt
M includes/api/ApiFeedContributions.php
2 files changed, 12 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/62/185062/1

diff --git a/docs/hooks.txt b/docs/hooks.txt
index 2de78dd..664bedd 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -372,6 +372,11 @@
 $text : the new text of the article (has yet to be saved)
 &$resultArr : data in this array will be added to the API result
 
+`ApiFeedContributions::feedItem`: Called to convert the result of ContribsPager
+into a FeedItem instance that ApiFeedContributions can consume.
+$row: A row of data from ContribsPager
+&$feedItem: Set this to a FeedItem instance if the hook can handle the 
provided row
+
 'ApiFormatHighlight': Use to syntax-highlight API pretty-printed output. When
 highlighting, add output to $context->getOutput() and return false.
 $context: An IContextSource.
diff --git a/includes/api/ApiFeedContributions.php 
b/includes/api/ApiFeedContributions.php
index ced5f0c..10f3e3d 100644
--- a/includes/api/ApiFeedContributions.php
+++ b/includes/api/ApiFeedContributions.php
@@ -103,6 +103,13 @@
        }
 
        protected function feedItem( $row ) {
+               // This is the api contributions equivalent to the 
+               // ContributionsLineEnding hook.
+               wfRunHooks( 'ApiFeedContributions::feedItem', $row, &$feedItem 
);
+               if ( $feedItem instanceof FeedItem ) {
+                       return $feedItem;
+               }
+
                $title = Title::makeTitle( intval( $row->page_namespace ), 
$row->page_title );
                if ( $title && $title->userCan( 'read', $this->getUser() ) ) {
                        $date = $row->rev_timestamp;

-- 
To view, visit https://gerrit.wikimedia.org/r/185062
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I27c77cc682ba801c40361c76b67398108ca1a592
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to