57 $this->mRegex = $regex;
67 global $wgTitleBlacklistUsernameSources;
69 if ( $wgTitleBlacklistUsernameSources ===
'*' ) {
73 if ( !$wgTitleBlacklistUsernameSources ) {
77 if ( !is_array( $wgTitleBlacklistUsernameSources ) ) {
79 '$wgTitleBlacklistUsernameSources must be "*", false or an array' );
82 return in_array( $this->mSource, $wgTitleBlacklistUsernameSources,
true );
93 public function matches( $title, $action ) {
102 if ( isset( $this->mParams[
'antispoof'] )
103 && is_callable(
'AntiSpoof::checkUnicodeString' )
105 if ( $action ===
'edit' ) {
107 $cache = ObjectCache::getMainWANInstance();
108 list( $ok, $norm ) =
$cache->getWithSetCallback(
109 $cache->makeKey(
'titleblacklist',
'normalized-unicode', md5( $title ) ),
111 function () use ( $title ) {
112 return AntiSpoof::checkUnicodeString( $title );
114 [
'pcTTL' => $cache::TTL_PROC_LONG ]
117 list( $ok, $norm ) = AntiSpoof::checkUnicodeString( $title );
120 if ( $ok ===
"OK" ) {
121 list( $ver, $title ) = explode(
':', $norm, 2 );
123 wfDebugLog(
'TitleBlacklist',
'AntiSpoof could not normalize "' . $title .
'".' );
129 "/^(?:{$this->mRegex})$/us" . ( isset( $this->mParams[
'casesensitive'] ) ?
'' :
'i' ),
135 if ( isset( $this->mParams[
'moveonly'] ) && $action !=
'move' ) {
138 if ( isset( $this->mParams[
'newaccountonly'] ) && $action !=
'new-account' ) {
141 if ( !isset( $this->mParams[
'noedit'] ) && $action ==
'edit' ) {
144 if ( isset( $this->mParams[
'reupload'] ) && $action ==
'upload' ) {
165 $line = preg_replace(
"/^\\s*([^#]*)\\s*((.*)?)$/",
"\\1",
$line );
168 if (
$line ===
'' ) {
173 if ( !preg_match(
'/^(.*?)(\s*<([^<>]*)>)?$/',
$line, $pockets ) ) {
176 $regex = trim( $pockets[1] );
177 $regex = str_replace(
'_',
' ', $regex );
178 $opts_str = isset( $pockets[3] ) ? trim( $pockets[3] ) :
'';
180 $opts = preg_split(
'/\s*\|\s*/', $opts_str );
181 foreach ( $opts as
$opt ) {
182 $opt2 = strtolower(
$opt );
183 if ( $opt2 ==
'autoconfirmed' ) {
186 if ( $opt2 ==
'moveonly' ) {
189 if ( $opt2 ==
'newaccountonly' ) {
192 if ( $opt2 ==
'noedit' ) {
195 if ( $opt2 ==
'casesensitive' ) {
198 if ( $opt2 ==
'reupload' ) {
201 if ( preg_match(
'/errmsg\s*=\s*(.+)/i',
$opt,
$matches ) ) {
204 if ( $opt2 ==
'antispoof' ) {
209 preg_match_all(
'/{{\s*([a-z]+)\s*:\s*(.+?)\s*}}/', $regex, $magicwords, PREG_SET_ORDER );
210 foreach ( $magicwords as $mword ) {
212 switch ( strtolower( $mword[1] ) ) {
215 if ( is_string( $cpf_result ) ) {
217 $regex = str_replace( $mword[0], $cpf_result, $regex );
221 $cpf_result =
wfMessage( $mword[2] )->inContentLanguage()->text();
222 if ( is_string( $cpf_result ) ) {
223 $regex = str_replace( $mword[0], $cpf_result, $regex );
260 return isset( $this->mParams[
'errmsg'] ) ? $this->mParams[
'errmsg'] :
null;
276 $this->mFormatVersion = $v;
291 return $message ? $message :
"titleblacklist-forbidden-{$operation}";
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
static ns( $parser, $part1='')
Represents a title blacklist entry.
string $mFormatVersion
Entry format version.
string $mSource
Source of this entry.
static newFromString( $line, $source)
Create a new TitleBlacklistEntry from a line of text.
getErrorMessage( $operation)
Return the error message name for the blacklist entry.
array $mParams
Parameters for this entry.
string $mRegex
Regular expression to match.
__construct( $regex, $params, $raw, $source)
Construct a new TitleBlacklistEntry.
matches( $title, $action)
Check whether a user can perform the specified action on the specified Title.
filtersNewAccounts()
Returns whether this entry is capable of filtering new accounts.
setFormatVersion( $v)
Set the format version.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services