MediaWiki master
NamedConditionHelper.php
Go to the documentation of this file.
1<?php
2
4
6use stdClass;
9
16 public function __construct(
17 private TempUserConfig $tempUserConfig
18 ) {
19 }
20
27 public function isNamed( stdClass $row ) {
28 return $row->rc_user && !$this->tempUserConfig->isTempName( $row->rc_user_text );
29 }
30
36 public function getExpression( IReadableDatabase $dbr, bool $isNamed ) {
37 $expr = $dbr->expr( 'actor_user', $isNamed ? '!=' : '=', null );
38 if ( !$this->tempUserConfig->isKnown() ) {
39 return $expr;
40 }
41 if ( $isNamed ) {
42 return $expr->andExpr( $this->tempUserConfig->getMatchCondition( $dbr,
43 'actor_name', IExpression::NOT_LIKE ) );
44 } else {
45 return $expr->orExpr( $this->tempUserConfig->getMatchCondition( $dbr,
46 'actor_name', IExpression::LIKE ) );
47 }
48 }
49
50}
Shared code between the named and experience filter conditions.
isNamed(stdClass $row)
Determine whether a result row contains a named user.
Interface for temporary user creation config and name matching.
A database connection without write operations.
expr(string $field, string $op, $value)
See Expression::__construct()