77 $this->loadBalancer = $loadBalancer;
78 $this->commentStore = $commentStore;
79 $this->actorMigration = $actorMigration;
80 $this->watchedItemStore = $watchedItemStore;
87 if ( $this->extensions ===
null ) {
88 $this->extensions = [];
89 Hooks::run(
'WatchedItemQueryServiceExtensions', [ &$this->extensions, $this ] );
91 return $this->extensions;
98 return $this->loadBalancer->getConnectionRef(
DB_REPLICA, [
'watchlist' ] );
148 'includeFields' => [],
149 'namespaceIds' => [],
151 'allRevisions' =>
false,
152 'usedInGenerator' =>
false
158 '$options[\'rcTypes\']',
159 'must be an array containing only: RC_EDIT, RC_NEW, RC_LOG, RC_EXTERNAL and/or RC_CATEGORIZE'
164 'must be DIR_OLDER or DIR_NEWER'
170 'must be provided when providing the "start" or "end" options or the $startFrom parameter'
174 '$options[\'startFrom\']',
175 'must not be provided, use $startFrom instead'
178 !
isset( $startFrom ) || (
is_array( $startFrom ) && count( $startFrom ) === 2 ),
180 'must be a two-element array'
183 Assert::parameterType(
186 '$options[\'watchlistOwner\']'
190 '$options[\'watchlistOwnerToken\']',
191 'must be provided when providing watchlistOwner option'
203 if ( $startFrom !==
null ) {
208 $extension->modifyWatchedItemsWithRCInfoQuery(
227 $limit = $dbOptions[
'LIMIT'] ??
INF;
230 foreach (
$res as $row ) {
231 if ( --$limit <= 0 ) {
232 $startFrom = [ $row->rc_timestamp, $row->rc_id ];
236 $target =
new TitleValue( (
int)$row->rc_namespace, $row->rc_title );
241 $this->watchedItemStore->getLatestNotificationTimestamp(
242 $row->wl_notificationtimestamp, $user, $target
250 $extension->modifyWatchedItemsWithRCInfo( $user,
$options, $db, $items,
$res, $startFrom );
276 if ( $user->isAnon() ) {
282 $options += [
'namespaceIds' => [] ];
286 '$options[\'sort\']',
287 'must be SORT_ASC or SORT_DESC'
291 $options[
'filter'], [ self::FILTER_CHANGED, self::FILTER_NOT_CHANGED ]
293 '$options[\'filter\']',
294 'must be FILTER_CHANGED or FILTER_NOT_CHANGED'
299 '$options[\'sort\']',
300 'must be provided if any of "from", "until", "startFrom" options is provided'
310 [
'wl_namespace',
'wl_title',
'wl_notificationtimestamp' ],
317 foreach (
$res as $row ) {
318 $target =
new TitleValue( (
int)$row->wl_namespace, $row->wl_title );
323 $this->watchedItemStore->getLatestNotificationTimestamp(
324 $row->wl_notificationtimestamp, $user, $target
339 return substr( $key, 0, 3 ) ===
'rc_';
346 $tables = [
'recentchanges',
'watchlist' ];
351 $tables += $this->commentStore->getJoin(
'rc_comment' )[
'tables'];
359 $tables += $this->actorMigration->getJoin(
'rc_user' )[
'tables'];
372 'wl_notificationtimestamp'
380 if (
$options[
'usedInGenerator'] ) {
382 $rcIdFields = [
'rc_this_oldid' ];
384 $rcIdFields = [
'rc_cur_id' ];
390 $fields =
array_merge( $fields, [
'rc_type',
'rc_minor',
'rc_bot' ] );
393 $fields[
'rc_user_text'] = $this->actorMigration->getJoin(
'rc_user' )[
'fields'][
'rc_user_text'];
396 $fields[
'rc_user'] = $this->actorMigration->getJoin(
'rc_user' )[
'fields'][
'rc_user'];
399 $fields += $this->commentStore->getJoin(
'rc_comment' )[
'fields'];
402 $fields =
array_merge( $fields, [
'rc_patrolled',
'rc_log_type' ] );
405 $fields =
array_merge( $fields, [
'rc_old_len',
'rc_new_len' ] );
408 $fields =
array_merge( $fields, [
'rc_logid',
'rc_log_type',
'rc_log_action',
'rc_params' ] );
428 [
'rc_this_oldid=page_latest',
'rc_type=' .
RC_LOG ],
450 $conds[] =
'rc_timestamp > ' . $db->
addQuotes(
'' );
456 if ( $deletedPageLogCond ) {
466 $watchlistOwner =
$options[
'watchlistOwner'];
467 $ownersToken = $watchlistOwner->getOption(
'watchlisttoken' );
468 $token =
$options[
'watchlistOwnerToken'];
469 if ( $ownersToken ==
'' || !
hash_equals( $ownersToken, $token ) ) {
472 return $watchlistOwner->getId();
474 return $user->getId();
481 $conds[] =
'rc_minor != 0';
483 $conds[] =
'rc_minor = 0';
487 $conds[] =
'rc_bot != 0';
489 $conds[] =
'rc_bot = 0';
493 $conds[] = $this->actorMigration->isAnon(
494 $this->actorMigration->getJoin(
'rc_user' )[
'fields'][
'rc_user']
497 $conds[] = $this->actorMigration->isNotAnon(
498 $this->actorMigration->getJoin(
'rc_user' )[
'fields'][
'rc_user']
502 if ( $user->useRCPatrol() || $user->useNPPatrol() ) {
506 $conds[] =
'rc_patrolled != ' . RecentChange::PRC_UNPATROLLED;
508 $conds[
'rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
512 $conds[
'rc_patrolled'] = RecentChange::PRC_AUTOPATROLLED;
514 $conds[] =
'rc_patrolled != ' . RecentChange::PRC_AUTOPATROLLED;
519 $conds[] =
'rc_timestamp >= wl_notificationtimestamp';
522 $conds[] =
'wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp';
536 $after =
$options[
'dir'] === self::DIR_OLDER ?
'<=' :
'>=';
537 $conds[] =
'rc_timestamp ' . $after .
' ' .
541 $before =
$options[
'dir'] === self::DIR_OLDER ?
'>=' :
'<=';
542 $conds[] =
'rc_timestamp ' . $before .
' ' .
558 $conds[] = $this->actorMigration->getWhere( $db,
'rc_user', $byUser )[
'conds'];
561 $conds[] =
'NOT(' . $this->actorMigration->getWhere( $db,
'rc_user', $byUser )[
'conds'] .
')';
566 if ( !$user->isAllowed(
'deletedhistory' ) ) {
568 }
elseif ( !$user->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
572 $conds[] = $db->
bitAnd(
'rc_deleted', $bitmask ) .
" != $bitmask";
582 if ( !$user->isAllowed(
'deletedhistory' ) ) {
584 }
elseif ( !$user->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
590 $db->
bitAnd(
'rc_deleted', $bitmask ) .
" != $bitmask",
597 $op =
$options[
'dir'] === self::DIR_OLDER ?
'<' :
'>';
603 "rc_timestamp $op $rcTimestamp",
606 "rc_timestamp = $rcTimestamp",
617 $conds = [
'wl_user' => $user->getId() ];
623 if (
$filter === self::FILTER_CHANGED ) {
624 $conds[] =
'wl_notificationtimestamp IS NOT NULL';
626 $conds[] =
'wl_notificationtimestamp IS NULL';
631 $op =
$options[
'sort'] === self::SORT_ASC ?
'>' :
'<';
635 $op =
$options[
'sort'] === self::SORT_ASC ?
'<' :
'>';
639 $op =
$options[
'sort'] === self::SORT_ASC ?
'>' :
'<';
676 $dbOptions[
'ORDER BY'] = [
'rc_timestamp' .
$sort,
'rc_id' .
$sort ];
689 $dbOptions[
'ORDER BY'] = [
690 "wl_namespace {$options['sort']}",
691 "wl_title {$options['sort']}"
693 if ( count(
$options[
'namespaceIds'] ) === 1 ) {
694 $dbOptions[
'ORDER BY'] =
"wl_title {$options['sort']}";
705 'watchlist' => [
'JOIN',
707 'wl_namespace=rc_namespace',
713 $joinConds[
'page'] = [
'LEFT JOIN',
'rc_cur_id=page_id' ];
716 $joinConds += $this->commentStore->getJoin(
'rc_comment' )[
'joins'];
724 $joinConds += $this->actorMigration->getJoin(
'rc_user' )[
'joins'];
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
This class handles the logic for the actor table migration.
static newWithMessage(ApiBase $module=null, $msg, $code=null, $data=null, $httpCode=0)
Represents a page (or page fragment) title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
getWatchedItemsForUser(User $user, array $options=[])
For simple listing of user's watchlist items, see WatchedItemStore::getWatchedItemsForUser.
const INCLUDE_AUTOPATROL_INFO
const FILTER_NOT_AUTOPATROLLED
getExtraDeletedPageLogEntryRelatedCond(IDatabase $db, User $user)
WatchedItemQueryServiceExtension[] null $extensions
getUserRelatedConds(IDatabase $db, User $user, array $options)
const INCLUDE_PATROL_INFO
getWatchedItemsWithRCInfoQueryDbOptions(array $options)
getWatchedItemsWithRCInfoQueryFilterConds(User $user, array $options)
getWatchedItemsWithRCInfoQueryTables(array $options)
getWatchedItemsWithRCInfoQueryFields(array $options)
getWatchedItemsWithRCInfoQueryConds(IDatabase $db, User $user, array $options)
WatchedItemStoreInterface $watchedItemStore
getWatchedItemsForUserQueryConds(IDatabase $db, User $user, array $options)
const FILTER_AUTOPATROLLED
getFromUntilTargetConds(IDatabase $db, LinkTarget $target, $op)
Creates a query condition part for getting only items before or after the given link target (while or...
__construct(LoadBalancer $loadBalancer, CommentStore $commentStore, ActorMigration $actorMigration, WatchedItemStoreInterface $watchedItemStore)
LoadBalancer $loadBalancer
getStartEndConds(IDatabase $db, array $options)
ActorMigration $actorMigration
const FILTER_NOT_PATROLLED
getWatchlistOwnerId(User $user, array $options)
getWatchedItemsWithRecentChangeInfo(User $user, array $options=[], &$startFrom=null)
getWatchedItemsWithRCInfoQueryJoinConds(array $options)
getWatchedItemsForUserQueryDbOptions(array $options)
getRecentChangeFieldsFromRow(stdClass $row)
getStartFromConds(IDatabase $db, array $options, array $startFrom)
CommentStore $commentStore
Representation of a pair of user and title for watchlist entries.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
processing should stop and the error should be shown to the user * false
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))