Go to the documentation of this file.
5 use Wikimedia\Assert\Assert;
78 return $this->loadBalancer->getConnectionRef(
DB_REPLICA, [
'watchlist' ] );
128 'includeFields' => [],
129 'namespaceIds' => [],
131 'allRevisions' =>
false,
132 'usedInGenerator' =>
false
138 '$options[\'rcTypes\']',
139 'must be an array containing only: RC_EDIT, RC_NEW, RC_LOG, RC_EXTERNAL and/or RC_CATEGORIZE'
142 !isset(
$options[
'dir'] ) || in_array(
$options[
'dir'], [ self::DIR_OLDER, self::DIR_NEWER ] ),
144 'must be DIR_OLDER or DIR_NEWER'
147 !isset(
$options[
'start'] ) && !isset(
$options[
'end'] ) && $startFrom ===
null
150 'must be provided when providing the "start" or "end" options or the $startFrom parameter'
154 '$options[\'startFrom\']',
155 'must not be provided, use $startFrom instead'
158 !isset( $startFrom ) || ( is_array( $startFrom ) &&
count( $startFrom ) === 2 ),
160 'must be a two-element array'
162 if ( array_key_exists(
'watchlistOwner',
$options ) ) {
163 Assert::parameterType(
166 '$options[\'watchlistOwner\']'
169 isset(
$options[
'watchlistOwnerToken'] ),
170 '$options[\'watchlistOwnerToken\']',
171 'must be provided when providing watchlistOwner option'
175 $tables = [
'recentchanges',
'watchlist' ];
187 if ( $startFrom !==
null ) {
192 $extension->modifyWatchedItemsWithRCInfoQuery(
211 $limit = isset( $dbOptions[
'LIMIT'] ) ? $dbOptions[
'LIMIT'] : INF;
214 foreach (
$res as $row ) {
216 $startFrom = [ $row->rc_timestamp, $row->rc_id ];
223 new TitleValue( (
int)$row->rc_namespace, $row->rc_title ),
224 $row->wl_notificationtimestamp
231 $extension->modifyWatchedItemsWithRCInfo(
$user,
$options, $db, $items,
$res, $startFrom );
257 if (
$user->isAnon() ) {
263 $options += [
'namespaceIds' => [] ];
266 !isset(
$options[
'sort'] ) || in_array(
$options[
'sort'], [ self::SORT_ASC, self::SORT_DESC ] ),
267 '$options[\'sort\']',
268 'must be SORT_ASC or SORT_DESC'
271 !isset(
$options[
'filter'] ) || in_array(
272 $options[
'filter'], [ self::FILTER_CHANGED, self::FILTER_NOT_CHANGED ]
274 '$options[\'filter\']',
275 'must be FILTER_CHANGED or FILTER_NOT_CHANGED'
280 '$options[\'sort\']',
281 'must be provided if any of "from", "until", "startFrom" options is provided'
291 [
'wl_namespace',
'wl_title',
'wl_notificationtimestamp' ],
298 foreach (
$res as $row ) {
302 new TitleValue( (
int)$row->wl_namespace, $row->wl_title ),
303 $row->wl_notificationtimestamp
307 return $watchedItems;
313 $allFields = get_object_vars( $row );
314 $rcKeys = array_filter(
315 array_keys( $allFields ),
317 return substr( $key, 0, 3 ) ===
'rc_';
320 return array_intersect_key( $allFields, array_flip( $rcKeys ) );
331 'wl_notificationtimestamp'
339 if (
$options[
'usedInGenerator'] ) {
341 $rcIdFields = [
'rc_this_oldid' ];
343 $rcIdFields = [
'rc_cur_id' ];
346 $fields = array_merge( $fields, $rcIdFields );
348 if ( in_array( self::INCLUDE_FLAGS,
$options[
'includeFields'] ) ) {
349 $fields = array_merge( $fields, [
'rc_type',
'rc_minor',
'rc_bot' ] );
351 if ( in_array( self::INCLUDE_USER,
$options[
'includeFields'] ) ) {
352 $fields[] =
'rc_user_text';
354 if ( in_array( self::INCLUDE_USER_ID,
$options[
'includeFields'] ) ) {
355 $fields[] =
'rc_user';
357 if ( in_array( self::INCLUDE_COMMENT,
$options[
'includeFields'] ) ) {
358 $fields[] =
'rc_comment';
360 if ( in_array( self::INCLUDE_PATROL_INFO,
$options[
'includeFields'] ) ) {
361 $fields = array_merge( $fields, [
'rc_patrolled',
'rc_log_type' ] );
363 if ( in_array( self::INCLUDE_SIZES,
$options[
'includeFields'] ) ) {
364 $fields = array_merge( $fields, [
'rc_old_len',
'rc_new_len' ] );
366 if ( in_array( self::INCLUDE_LOG_INFO,
$options[
'includeFields'] ) ) {
367 $fields = array_merge( $fields, [
'rc_logid',
'rc_log_type',
'rc_log_action',
'rc_params' ] );
379 $conds = [
'wl_user' => $watchlistOwnerId ];
383 [
'rc_this_oldid=page_latest',
'rc_type=' .
RC_LOG ],
389 $conds[
'wl_namespace'] = array_map(
'intval',
$options[
'namespaceIds'] );
392 if ( array_key_exists(
'rcTypes',
$options ) ) {
393 $conds[
'rc_type'] = array_map(
'intval',
$options[
'rcTypes'] );
396 $conds = array_merge(
404 if ( $db->
getType() ===
'mysql' ) {
406 $conds[] =
'rc_timestamp > ' . $db->
addQuotes(
'' );
413 if ( $deletedPageLogCond ) {
414 $conds[] = $deletedPageLogCond;
421 if ( array_key_exists(
'watchlistOwner',
$options ) ) {
423 $watchlistOwner =
$options[
'watchlistOwner'];
424 $ownersToken = $watchlistOwner->getOption(
'watchlisttoken' );
425 $token =
$options[
'watchlistOwnerToken'];
426 if ( $ownersToken ==
'' || !hash_equals( $ownersToken, $token ) ) {
429 return $watchlistOwner->getId();
431 return $user->getId();
437 if ( in_array( self::FILTER_MINOR,
$options[
'filters'] ) ) {
438 $conds[] =
'rc_minor != 0';
439 } elseif ( in_array( self::FILTER_NOT_MINOR,
$options[
'filters'] ) ) {
440 $conds[] =
'rc_minor = 0';
443 if ( in_array( self::FILTER_BOT,
$options[
'filters'] ) ) {
444 $conds[] =
'rc_bot != 0';
445 } elseif ( in_array( self::FILTER_NOT_BOT,
$options[
'filters'] ) ) {
446 $conds[] =
'rc_bot = 0';
449 if ( in_array( self::FILTER_ANON,
$options[
'filters'] ) ) {
450 $conds[] =
'rc_user = 0';
451 } elseif ( in_array( self::FILTER_NOT_ANON,
$options[
'filters'] ) ) {
452 $conds[] =
'rc_user != 0';
455 if (
$user->useRCPatrol() ||
$user->useNPPatrol() ) {
458 if ( in_array( self::FILTER_PATROLLED,
$options[
'filters'] ) ) {
459 $conds[] =
'rc_patrolled != 0';
460 } elseif ( in_array( self::FILTER_NOT_PATROLLED,
$options[
'filters'] ) ) {
461 $conds[] =
'rc_patrolled = 0';
465 if ( in_array( self::FILTER_UNREAD,
$options[
'filters'] ) ) {
466 $conds[] =
'rc_timestamp >= wl_notificationtimestamp';
467 } elseif ( in_array( self::FILTER_NOT_UNREAD,
$options[
'filters'] ) ) {
469 $conds[] =
'wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp';
483 $after =
$options[
'dir'] === self::DIR_OLDER ?
'<=' :
'>=';
484 $conds[] =
'rc_timestamp ' . $after .
' ' .
488 $before =
$options[
'dir'] === self::DIR_OLDER ?
'>=' :
'<=';
489 $conds[] =
'rc_timestamp ' . $before .
' ' .
497 if ( !array_key_exists(
'onlyByUser',
$options ) && !array_key_exists(
'notByUser',
$options ) ) {
503 if ( array_key_exists(
'onlyByUser',
$options ) ) {
504 $conds[
'rc_user_text'] =
$options[
'onlyByUser'];
505 } elseif ( array_key_exists(
'notByUser',
$options ) ) {
511 if ( !
$user->isAllowed(
'deletedhistory' ) ) {
513 } elseif ( !
$user->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
517 $conds[] = $db->
bitAnd(
'rc_deleted', $bitmask ) .
" != $bitmask";
527 if ( !
$user->isAllowed(
'deletedhistory' ) ) {
529 } elseif ( !
$user->isAllowedAny(
'suppressrevision',
'viewsuppressed' ) ) {
535 $db->
bitAnd(
'rc_deleted', $bitmask ) .
" != $bitmask",
542 $op =
$options[
'dir'] === self::DIR_OLDER ?
'<' :
'>';
543 list( $rcTimestamp, $rcId ) = $startFrom;
548 "rc_timestamp $op $rcTimestamp",
551 "rc_timestamp = $rcTimestamp",
562 $conds = [
'wl_user' =>
$user->getId() ];
564 $conds[
'wl_namespace'] = array_map(
'intval',
$options[
'namespaceIds'] );
566 if ( isset(
$options[
'filter'] ) ) {
568 if ( $filter === self::FILTER_CHANGED ) {
569 $conds[] =
'wl_notificationtimestamp IS NOT NULL';
571 $conds[] =
'wl_notificationtimestamp IS NULL';
576 $op =
$options[
'sort'] === self::SORT_ASC ?
'>' :
'<';
580 $op =
$options[
'sort'] === self::SORT_ASC ?
'<' :
'>';
583 if ( isset(
$options[
'startFrom'] ) ) {
584 $op =
$options[
'sort'] === self::SORT_ASC ?
'>' :
'<';
619 if ( array_key_exists(
'dir',
$options ) ) {
621 $dbOptions[
'ORDER BY'] = [
'rc_timestamp' .
$sort,
'rc_id' .
$sort ];
624 if ( array_key_exists(
'limit',
$options ) ) {
625 $dbOptions[
'LIMIT'] = (int)
$options[
'limit'] + 1;
633 if ( array_key_exists(
'sort',
$options ) ) {
634 $dbOptions[
'ORDER BY'] = [
635 "wl_namespace {$options['sort']}",
636 "wl_title {$options['sort']}"
639 $dbOptions[
'ORDER BY'] =
"wl_title {$options['sort']}";
642 if ( array_key_exists(
'limit',
$options ) ) {
643 $dbOptions[
'LIMIT'] = (int)
$options[
'limit'];
650 'watchlist' => [
'INNER JOIN',
652 'wl_namespace=rc_namespace',
658 $joinConds[
'page'] = [
'LEFT JOIN',
'rc_cur_id=page_id' ];
getFromUntilTargetConds(IDatabase $db, LinkTarget $target, $op)
Creates a query condition part for getting only items before or after the given link target (while or...
getWatchedItemsWithRCInfoQueryConds(IDatabase $db, User $user, array $options)
getWatchedItemsWithRCInfoQueryJoinConds(array $options)
getUserRelatedConds(IDatabase $db, User $user, array $options)
processing should stop and the error should be shown to the user * false
this hook is for auditing only RecentChangesLinked and Watchlist 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
LoadBalancer $loadBalancer
getWatchedItemsForUserQueryConds(IDatabase $db, User $user, array $options)
getWatchedItemsWithRCInfoQueryFields(array $options)
getStartEndConds(IDatabase $db, array $options)
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
getExtraDeletedPageLogEntryRelatedCond(IDatabase $db, User $user)
getWatchedItemsWithRCInfoQueryDbOptions(array $options)
getWatchedItemsForUserQueryDbOptions(array $options)
getWatchedItemsWithRecentChangeInfo(User $user, array $options=[], &$startFrom=null)
static newWithMessage(ApiBase $module=null, $msg, $code=null, $data=null, $httpCode=0)
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
getWatchedItemsWithRCInfoQueryFilterConds(User $user, array $options)
const INCLUDE_PATROL_INFO
this hook is for auditing only RecentChangesLinked and Watchlist 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 and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers please use GetContentModels hook to make them known to core if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
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
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types as usual *javascript user provided javascript code *json simple implementation for use by extensions
getRecentChangeFieldsFromRow(stdClass $row)
Representation of a pair of user and title for watchlist entries.
const FILTER_NOT_PATROLLED
__construct(LoadBalancer $loadBalancer)
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getWatchlistOwnerId(User $user, array $options)
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
getWatchedItemsForUser(User $user, array $options=[])
For simple listing of user's watchlist items, see WatchedItemStore::getWatchedItemsForUser.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
WatchedItemQueryServiceExtension[] null $extensions
this hook is for auditing only RecentChangesLinked and Watchlist 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 and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
the array() calling protocol came about after MediaWiki 1.4rc1.
Represents a page (or page fragment) title within MediaWiki.
getStartFromConds(IDatabase $db, array $options, array $startFrom)