MediaWiki master
NamedConditionHelper.php
Go to the documentation of this file.
1<?php
2
4
6use stdClass;
9
18 public function __construct(
19 private TempUserConfig $tempUserConfig
20 ) {
21 }
22
29 public function isNamed( stdClass $row ) {
30 return $row->rc_user && !$this->tempUserConfig->isTempName( $row->rc_user_text );
31 }
32
38 public function getExpression( IReadableDatabase $dbr, bool $isNamed ) {
39 $expr = $dbr->expr( 'actor_user', $isNamed ? '!=' : '=', null );
40 if ( !$this->tempUserConfig->isKnown() ) {
41 return $expr;
42 }
43 if ( $isNamed ) {
44 return $expr->andExpr( $this->tempUserConfig->getMatchCondition( $dbr,
45 'actor_name', IExpression::NOT_LIKE ) );
46 } else {
47 return $expr->orExpr( $this->tempUserConfig->getMatchCondition( $dbr,
48 'actor_name', IExpression::LIKE ) );
49 }
50 }
51
52}
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()