Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3namespace MediaWiki\User\TempUser;
4
5use MediaWiki\Permissions\Authority;
6use Wikimedia\Rdbms\IExpression;
7use Wikimedia\Rdbms\IReadableDatabase;
8
9/**
10 * Interface for temporary user creation config and name matching.
11 *
12 * This is separate from TempUserCreator to avoid dependency loops during
13 * service construction, since TempUserCreator needs UserNameUtils which
14 * needs TempUserConfig.
15 *
16 * @since 1.39
17 */
18interface TempUserConfig {
19    /**
20     * Is temp user creation enabled?
21     *
22     * @return bool
23     */
24    public function isEnabled();
25
26    /**
27     * Is the action valid for user auto-creation?
28     *
29     * @param string $action
30     * @return bool
31     */
32    public function isAutoCreateAction( string $action );
33
34    /**
35     * Should/would auto-create be performed if the user attempts to perform
36     * the given action?
37     *
38     * @since 1.41
39     * @param Authority $authority
40     * @param string $action
41     * @return bool
42     */
43    public function shouldAutoCreate( Authority $authority, string $action );
44
45    /**
46     * Does the name match the configured pattern indicating that it is a
47     * temporary auto-created user?
48     *
49     * @param string $name
50     * @return bool
51     */
52    public function isTempName( string $name );
53
54    /**
55     * Does the name match a configured pattern which indicates that it
56     * conflicts with temporary user names? Should manual user creation
57     * be denied?
58     *
59     * @param string $name
60     * @return mixed
61     */
62    public function isReservedName( string $name );
63
64    /**
65     * Get a placeholder name which matches the reserved prefix
66     *
67     * @return string
68     */
69    public function getPlaceholderName(): string;
70
71    /**
72     * Get a Pattern indicating how temporary account can be detected
73     *
74     * Used to avoid selecting a temp account via select queries.
75     *
76     * @deprecated since 1.42. Use ::getMatchPatterns as multiple patterns may be defined.
77     * @return Pattern
78     */
79    public function getMatchPattern(): Pattern;
80
81    /**
82     * Get Patterns indicating how temporary account can be detected
83     *
84     * Used to avoid selecting a temp account via select queries.
85     *
86     * @since 1.42
87     * @return Pattern[]
88     */
89    public function getMatchPatterns(): array;
90
91    /**
92     * Get a SQL query condition that will match (or not match) temporary accounts.
93     *
94     * @since 1.42
95     * @param IReadableDatabase $db
96     * @param string $field Database field to match against
97     * @param string $op Operator: IExpression::LIKE or IExpression::NOT_LIKE
98     * @return IExpression
99     */
100    public function getMatchCondition( IReadableDatabase $db, string $field, string $op ): IExpression;
101
102    /**
103     * After how many days do temporary users expire?
104     *
105     * @note expireTemporaryAccounts.php maintenance script needs to be periodically executed for
106     * temp account expiry to work.
107     * @since 1.42
108     * @return int|null Null if temp accounts should never expire
109     */
110    public function getExpireAfterDays(): ?int;
111
112    /**
113     * How many days before expiration should temporary users be notified?
114     *
115     * @note expireTemporaryAccounts.php maintenance script needs to be periodically executed for
116     * temp account expiry to work.
117     * @since 1.42
118     * @return int|null Null if temp accounts should never be notified before expiration
119     */
120    public function getNotifyBeforeExpirationDays(): ?int;
121}