MediaWiki  1.29.1
BaseBlacklist Class Reference

Base class for different kinds of blacklists. More...

Inheritance diagram for BaseBlacklist:

Public Member Functions

 __construct ( $settings=array())
 Constructor. More...
 
 buildSharedBlacklists ()
 
 clearCache ()
 Clear all primary blacklist cache keys. More...
 
 filter (array $links, Title $title, $preventLog=false)
 
 getArticleText ( $wiki, $article)
 Fetch an article from this or another local MediaWiki database. More...
 
 getBlacklists ()
 Fetch local and (possibly cached) remote blacklists. More...
 
 getHttpText ( $fileName)
 
 getLocalBlacklists ()
 Returns the local blacklist. More...
 
 getRegexEnd ( $batchSize)
 Returns the end of the regex for matches. More...
 
 getRegexStart ()
 Returns the start of the regex for matches. More...
 
 getSharedBlacklists ()
 Fetch (possibly cached) remote blacklists. More...
 
 getWhitelists ()
 Returns the (local) whitelist. More...
 
 warmCachesForFilter (Title $title, array $entries)
 

Static Public Member Functions

static addBlacklistType ( $type, $class)
 Adds a blacklist class to the registry. More...
 
static getBlacklistTypes ()
 Return the array of blacklist types currently defined. More...
 
static getInstance ( $type)
 Returns an instance of the given blacklist. More...
 
static getTypeFromTitle (Title $title)
 Returns the type of blacklist from the given title. More...
 
static isLocalSource (Title $title)
 Check if the given local page title is a spam regex source. More...
 

Public Attributes

int $expiryTime = 900
 
array $files = array()
 Array of blacklist sources. More...
 
int $warningChance = 100
 Chance of receiving a warning when the filter is hit. More...
 
int $warningTime = 600
 

Protected Member Functions

 getBlacklistType ()
 Returns the code for the blacklist implementation. More...
 

Protected Attributes

bool array $regexes = false
 Array containing regexes to test against. More...
 

Static Private Attributes

static array $blacklistTypes
 Array containing blacklists that extend BaseBlacklist. More...
 
static array $instances = array()
 Array of blacklist instances. More...
 

Detailed Description

Base class for different kinds of blacklists.

Definition at line 6 of file BaseBlacklist.php.

Constructor & Destructor Documentation

◆ __construct()

BaseBlacklist::__construct (   $settings = array())

Constructor.

Parameters
array$settings

Definition at line 60 of file BaseBlacklist.php.

References $name, $value, and as.

Member Function Documentation

◆ addBlacklistType()

static BaseBlacklist::addBlacklistType (   $type,
  $class 
)
static

Adds a blacklist class to the registry.

Parameters
$typestring
$classstring

Definition at line 80 of file BaseBlacklist.php.

References $type.

◆ buildSharedBlacklists()

BaseBlacklist::buildSharedBlacklists ( )

◆ clearCache()

BaseBlacklist::clearCache ( )

Clear all primary blacklist cache keys.

Note
: this method is unused atm

Definition at line 287 of file BaseBlacklist.php.

References $cache, getBlacklistType(), ObjectCache\getMainWANInstance(), wfDebugLog(), and wfMemcKey().

◆ filter()

BaseBlacklist::filter ( array  $links,
Title  $title,
  $preventLog = false 
)
abstract
Parameters
array$links
Title$title
bool$preventLog
Returns
mixed

Reimplemented in EmailBlacklist.

◆ getArticleText()

BaseBlacklist::getArticleText (   $wiki,
  $article 
)

Fetch an article from this or another local MediaWiki database.

This is probably very fragile, and shouldn't be used perhaps.

Parameters
string$wiki
string$article
Returns
string

Definition at line 365 of file BaseBlacklist.php.

References $article, $title, array(), DB_SLAVE, ContentHandler\getContentText(), Revision\newFromRow(), Title\newFromText(), Revision\selectFields(), Revision\selectPageFields(), Revision\selectTextFields(), wfDebugLog(), and wfGetDB().

Referenced by buildSharedBlacklists().

◆ getBlacklists()

BaseBlacklist::getBlacklists ( )

Fetch local and (possibly cached) remote blacklists.

Will be cached locally across multiple invocations.

Returns
array set of regular expressions, potentially empty.

Definition at line 201 of file BaseBlacklist.php.

References $regexes, getLocalBlacklists(), and getSharedBlacklists().

Referenced by EmailBlacklist\checkUser(), and SpamBlacklist\filter().

◆ getBlacklistType()

BaseBlacklist::getBlacklistType ( )
abstractprotected

Returns the code for the blacklist implementation.

Returns
string

Reimplemented in SpamBlacklist, and EmailBlacklist.

Referenced by buildSharedBlacklists(), clearCache(), getHttpText(), getLocalBlacklists(), getSharedBlacklists(), and getWhitelists().

◆ getBlacklistTypes()

static BaseBlacklist::getBlacklistTypes ( )
static

Return the array of blacklist types currently defined.

Returns
array

Definition at line 89 of file BaseBlacklist.php.

References $blacklistTypes.

Referenced by SpamBlacklistHooks\pageSaveContent().

◆ getHttpText()

BaseBlacklist::getHttpText (   $fileName)

Definition at line 326 of file BaseBlacklist.php.

References $messageMemc, $wgDBname, Http\get(), getBlacklistType(), global, and wfDebugLog().

Referenced by buildSharedBlacklists().

◆ getInstance()

◆ getLocalBlacklists()

BaseBlacklist::getLocalBlacklists ( )

Returns the local blacklist.

Returns
array Regular expressions

Definition at line 215 of file BaseBlacklist.php.

References $type, getBlacklistType(), ObjectCache\getMainWANInstance(), SpamRegexBatch\regexesFromMessage(), use, and wfMemcKey().

Referenced by getBlacklists().

◆ getRegexEnd()

BaseBlacklist::getRegexEnd (   $batchSize)

Returns the end of the regex for matches.

Parameters
$batchSize
Returns
string

Reimplemented in SpamBlacklist.

Definition at line 409 of file BaseBlacklist.php.

Referenced by SpamRegexBatch\buildRegexes().

◆ getRegexStart()

BaseBlacklist::getRegexStart ( )

Returns the start of the regex for matches.

Returns
string

Reimplemented in SpamBlacklist.

Definition at line 399 of file BaseBlacklist.php.

Referenced by SpamRegexBatch\buildRegexes().

◆ getSharedBlacklists()

BaseBlacklist::getSharedBlacklists ( )

Fetch (possibly cached) remote blacklists.

Returns
array

Definition at line 250 of file BaseBlacklist.php.

References $regexes, array(), captcha-old\count, files, getBlacklistType(), ObjectCache\getMainWANInstance(), use, wfDebugLog(), and wfMemcKey().

Referenced by getBlacklists().

◆ getTypeFromTitle()

static BaseBlacklist::getTypeFromTitle ( Title  $title)
static

Returns the type of blacklist from the given title.

Parameters
Title$title
Returns
bool|string

Definition at line 185 of file BaseBlacklist.php.

References $title, and array().

Referenced by SpamBlacklistHooks\validate().

◆ getWhitelists()

BaseBlacklist::getWhitelists ( )

Returns the (local) whitelist.

Returns
array Regular expressions

Definition at line 233 of file BaseBlacklist.php.

References $type, getBlacklistType(), ObjectCache\getMainWANInstance(), SpamRegexBatch\regexesFromMessage(), use, and wfMemcKey().

Referenced by EmailBlacklist\checkUser(), and SpamBlacklist\filter().

◆ isLocalSource()

static BaseBlacklist::isLocalSource ( Title  $title)
static

Check if the given local page title is a spam regex source.

Parameters
Title$title
Returns
bool

Definition at line 133 of file BaseBlacklist.php.

References $files, $matches, $title, $type, $wgDBname, array(), as, global, NS_MEDIAWIKI, PROTO_HTTP, and wfExpandUrl().

Referenced by SpamBlacklistHooks\pageSaveContent(), and SpamBlacklistHooks\validate().

◆ warmCachesForFilter()

BaseBlacklist::warmCachesForFilter ( Title  $title,
array  $entries 
)
Parameters
Title$title
string[]$entries

Reimplemented in SpamBlacklist.

Definition at line 417 of file BaseBlacklist.php.

Member Data Documentation

◆ $blacklistTypes

array BaseBlacklist::$blacklistTypes
staticprivate
Initial value:
'spam' => 'SpamBlacklist',
'email' => 'EmailBlacklist',
)

Array containing blacklists that extend BaseBlacklist.

Definition at line 43 of file BaseBlacklist.php.

Referenced by getBlacklistTypes().

◆ $expiryTime

int BaseBlacklist::$expiryTime = 900

Definition at line 36 of file BaseBlacklist.php.

◆ $files

array BaseBlacklist::$files = array()

Array of blacklist sources.

Definition at line 12 of file BaseBlacklist.php.

Referenced by isLocalSource().

◆ $instances

array BaseBlacklist::$instances = array()
staticprivate

Array of blacklist instances.

Definition at line 53 of file BaseBlacklist.php.

◆ $regexes

bool array BaseBlacklist::$regexes = false
protected

Array containing regexes to test against.

Definition at line 19 of file BaseBlacklist.php.

Referenced by buildSharedBlacklists(), getBlacklists(), and getSharedBlacklists().

◆ $warningChance

int BaseBlacklist::$warningChance = 100

Chance of receiving a warning when the filter is hit.

Definition at line 26 of file BaseBlacklist.php.

◆ $warningTime

int BaseBlacklist::$warningTime = 600

Definition at line 31 of file BaseBlacklist.php.


The documentation for this class was generated from the following file:
array
the array() calling protocol came about after MediaWiki 1.4rc1.