MediaWiki master
MediaWiki\Block\HideUserUtils Class Reference

Helpers for building queries that determine whether a user is hidden. More...

Public Member Functions

 __construct ( $blockTargetMigrationStage)
 
 addFieldToBuilder (SelectQueryBuilder $qb, $userIdField='user_id', $deletedFieldAlias='hu_deleted')
 Add a field and related joins to the query builder.
 
 getExpression (IReadableDatabase $dbr, string $userIdField='user_id', $status=self::SHOWN_USERS)
 Get an SQL expression suitable for use in WHERE clause which will be true for either hidden or non-hidden users as specified.
 

Public Attributes

const HIDDEN_USERS = 2
 Select users that are hidden.
 
const SHOWN_USERS = 1
 Select users that are not hidden.
 

Detailed Description

Helpers for building queries that determine whether a user is hidden.

Since
1.42

Definition at line 12 of file HideUserUtils.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Block\HideUserUtils::__construct (   $blockTargetMigrationStage)

Definition at line 26 of file HideUserUtils.php.

References SCHEMA_COMPAT_READ_MASK.

Member Function Documentation

◆ addFieldToBuilder()

MediaWiki\Block\HideUserUtils::addFieldToBuilder ( SelectQueryBuilder  $qb,
  $userIdField = 'user_id',
  $deletedFieldAlias = 'hu_deleted' 
)

Add a field and related joins to the query builder.

The field in the query result will be true if the user is hidden or false otherwise.

Note that a GROUP BY option will be set, to avoid duplicating the result row if the user is hidden by more than one block.

Parameters
SelectQueryBuilder$qbThe query builder to be modified
string$userIdFieldThe name of the user_id field to use in the join
string$deletedFieldAliasThe field alias which will contain the true if the user is deleted.

Definition at line 84 of file HideUserUtils.php.

References Wikimedia\Rdbms\SelectQueryBuilder\newJoinGroup(), SCHEMA_COMPAT_READ_OLD, and Wikimedia\Rdbms\SelectQueryBuilder\select().

◆ getExpression()

MediaWiki\Block\HideUserUtils::getExpression ( IReadableDatabase  $dbr,
string  $userIdField = 'user_id',
  $status = self::SHOWN_USERS 
)

Get an SQL expression suitable for use in WHERE clause which will be true for either hidden or non-hidden users as specified.

The expression will contain a subquery.

Parameters
IReadableDatabase$dbr
string$userIdFieldThe field to be used as the user_id when joining on block/ipblocks. Defaults to "user_id".
int$statusEither self::SHOWN_USERS or self::HIDDEN_USERS depending on what sort of user you want to match.
Returns
string

Definition at line 43 of file HideUserUtils.php.

References Wikimedia\Rdbms\IReadableDatabase\newSelectQueryBuilder(), and SCHEMA_COMPAT_READ_OLD.

Member Data Documentation

◆ HIDDEN_USERS

const MediaWiki\Block\HideUserUtils::HIDDEN_USERS = 2

Select users that are hidden.

Definition at line 21 of file HideUserUtils.php.

◆ SHOWN_USERS

const MediaWiki\Block\HideUserUtils::SHOWN_USERS = 1

Select users that are not hidden.

Definition at line 16 of file HideUserUtils.php.


The documentation for this class was generated from the following file: