wiki.techinc.nl/includes/WatchedItemQueryServiceExtension.php
Brad Jorsch 715cbe468b Add hooks for WatchedItemQueryService / ApiQueryWatchlist
In order for an extension to add data to ApiQueryWatchlist, we need to
provide a way to allow it to manipulate the database query made by
WatchedItemQueryService. We also need some hooks in ApiQueryWatchlist to
handle the marshalling of data to and from WatchedItemQueryService.

To better handle hooking, this also moves some of the continuation logic
from ApiQueryWatchlist to WatchedItemQueryService.

Bug: T147939
Change-Id: Ie45376980f92da964a579887b28175c00fd8f57e
2016-11-03 11:41:40 +00:00

54 lines
2 KiB
PHP

<?php
/**
* Extension mechanism for WatchedItemQueryService
*
* @since 1.29
*
* @file
* @ingroup Watchlist
*
* @license GNU GPL v2+
*/
interface WatchedItemQueryServiceExtension {
/**
* Modify the WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
* query before it's made.
*
* @warning Any joins added *must* join on a unique key of the target table
* unless you really know what you're doing.
* @param User $user
* @param array $options Options from
* WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
* @param IDatabase $db Database connection being used for the query
* @param array &$tables Tables for Database::select()
* @param array &$fields Fields for Database::select()
* @param array &$conds Conditions for Database::select()
* @param array &$dbOptions Options for Database::select()
* @param array &$joinConds Join conditions for Database::select()
*/
public function modifyWatchedItemsWithRCInfoQuery( User $user, array $options, IDatabase $db,
array &$tables, array &$fields, array &$conds, array &$dbOptions, array &$joinConds
);
/**
* Modify the results from WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
* before they're returned.
*
* @param User $user
* @param array $options Options from
* WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
* @param IDatabase $db Database connection being used for the query
* @param array &$items array of pairs ( WatchedItem $watchedItem, string[] $recentChangeInfo ).
* May be truncated if necessary, in which case $startFrom must be updated.
* @param ResultWrapper|bool $res Database query result
* @param array|null &$startFrom Continuation value. If you truncate $items, set this to
* [ $recentChangeInfo['rc_timestamp'], $recentChangeInfo['rc_id'] ] from the first item
* removed.
*/
public function modifyWatchedItemsWithRCInfo( User $user, array $options, IDatabase $db,
array &$items, $res, &$startFrom
);
}