MediaWiki master
WatchlistJoin.php
Go to the documentation of this file.
1<?php
2
4
6
14class WatchlistJoin extends BasicJoin {
15 private ?int $userId = null;
16
17 public function __construct() {
18 parent::__construct(
19 'watchlist',
20 '',
21 [
22 'wl_namespace=rc_namespace',
23 'wl_title=rc_title'
24 ]
25 );
26 }
27
33 public function setUser( UserIdentity $user ) {
34 $this->userId = $user->getId();
35 }
36
43 protected function getExtraConds( ?string $alias ) {
44 if ( $this->userId === null ) {
45 // Call ChangesListQuery::watchlistUser() before executing the query
46 throw new \LogicException( 'User ID must be set for watchlist join' );
47 }
48 if ( $this->userId === 0 ) {
49 // Don't ask for a watchlist join when the user is unregistered
50 throw new \LogicException( "Can't join on watchlist with wl_user=0" );
51 }
52 $field = 'wl_user';
53 if ( $alias !== null && $alias !== '' ) {
54 $field = "$alias.$field";
55 }
56 return [ $field => $this->userId ];
57 }
58}
A simple join with a fixed join condition.
Definition BasicJoin.php:15
A watchlist join with a settable condition on wl_user.
getExtraConds(?string $alias)
Add the wl_user condition.
setUser(UserIdentity $user)
Set the user whose watchlist will be queried.
Interface for objects representing user identity.
getId( $wikiId=self::LOCAL)