X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fwatcheditem%2FWatchedItemQueryService.php;h=b134bfe13c69bc184f89c8a7b00313211fda0a23;hb=e5ef0fd0c6607dd34f6dee69d716b159662a0a34;hp=3ebc94a5640a0aec7d28b897ea0761af4d0277d2;hpb=c7b0bb2459a6b14590b252935eccc2edfccae13b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/watcheditem/WatchedItemQueryService.php b/includes/watcheditem/WatchedItemQueryService.php index 3ebc94a564..b134bfe13c 100644 --- a/includes/watcheditem/WatchedItemQueryService.php +++ b/includes/watcheditem/WatchedItemQueryService.php @@ -1,8 +1,9 @@ string (format accepted by wfTimestamp) requires 'dir' option, * timestamp to end enumerating * 'watchlistOwner' => User user whose watchlist items should be listed if different - * than the one specified with $user param, - * requires 'watchlistOwnerToken' option + * than the one specified with $user param, requires + * 'watchlistOwnerToken' option * 'watchlistOwnerToken' => string a watchlist token used to access another user's * watchlist, used with 'watchlistOwnerToken' option * 'limit' => int maximum numbers of items to return @@ -131,7 +132,7 @@ class WatchedItemQueryService { * id fields ('rc_cur_id', 'rc_this_oldid', 'rc_last_oldid') * if false (default) * @param array|null &$startFrom Continuation value: [ string $rcTimestamp, int $rcId ] - * @return array of pairs ( WatchedItem $watchedItem, string[] $recentChangeInfo ), + * @return array[] Array of pairs ( WatchedItem $watchedItem, string[] $recentChangeInfo ), * where $recentChangeInfo contains the following keys: * - 'rc_id', * - 'rc_namespace', @@ -256,7 +257,7 @@ class WatchedItemQueryService { /** * For simple listing of user's watchlist items, see WatchedItemStore::getWatchedItemsForUser * - * @param User $user + * @param UserIdentity $user * @param array $options Allowed keys: * 'sort' => string optional sorting by namespace ID and title * one of the self::SORT_* constants @@ -272,8 +273,8 @@ class WatchedItemQueryService { * specified using the form option * @return WatchedItem[] */ - public function getWatchedItemsForUser( User $user, array $options = [] ) { - if ( $user->isAnon() ) { + public function getWatchedItemsForUser( UserIdentity $user, array $options = [] ) { + if ( !$user->isRegistered() ) { // TODO: should this just return an empty array or rather complain loud at this point // as e.g. ApiBase::getWatchlistUser does? return []; @@ -445,11 +446,9 @@ class WatchedItemQueryService { $conds = array_merge( $conds, $this->getStartEndConds( $db, $options ) ); - if ( !isset( $options['start'] ) && !isset( $options['end'] ) ) { - if ( $db->getType() === 'mysql' ) { - // This is an index optimization for mysql - $conds[] = 'rc_timestamp > ' . $db->addQuotes( '' ); - } + if ( !isset( $options['start'] ) && !isset( $options['end'] ) && $db->getType() === 'mysql' ) { + // This is an index optimization for mysql + $conds[] = 'rc_timestamp > ' . $db->addQuotes( '' ); } $conds = array_merge( $conds, $this->getUserRelatedConds( $db, $user, $options ) ); @@ -462,11 +461,12 @@ class WatchedItemQueryService { return $conds; } - private function getWatchlistOwnerId( User $user, array $options ) { + private function getWatchlistOwnerId( UserIdentity $user, array $options ) { if ( array_key_exists( 'watchlistOwner', $options ) ) { /** @var User $watchlistOwner */ $watchlistOwner = $options['watchlistOwner']; - $ownersToken = $watchlistOwner->getOption( 'watchlisttoken' ); + $ownersToken = + $watchlistOwner->getOption( 'watchlisttoken' ); $token = $options['watchlistOwnerToken']; if ( $ownersToken == '' || !hash_equals( $ownersToken, $token ) ) { throw ApiUsageException::newWithMessage( null, 'apierror-bad-watchlist-token', 'bad_wltoken' ); @@ -615,7 +615,9 @@ class WatchedItemQueryService { ); } - private function getWatchedItemsForUserQueryConds( IDatabase $db, User $user, array $options ) { + private function getWatchedItemsForUserQueryConds( + IDatabase $db, UserIdentity $user, array $options + ) { $conds = [ 'wl_user' => $user->getId() ]; if ( $options['namespaceIds'] ) { $conds['wl_namespace'] = array_map( 'intval', $options['namespaceIds'] );