MediaWiki REL1_33
SpamBlacklist Class Reference
Inheritance diagram for SpamBlacklist:
Collaboration diagram for SpamBlacklist:

Public Member Functions

 doLogging (User $user, Title $title, $revId)
 Actually push the url change events post-save.
 
 filter (array $links, Title $title=null, $preventLog=false, $mode='check')
 
 getCurrentLinks (Title $title)
 Look up the links currently in the article, so we can ignore them on a second run.
 
 getRegexEnd ( $batchSize)
 Returns the end of the regex for matches.
 
 getRegexStart ()
 Returns the start of the regex for matches.
 
 isLoggingEnabled ()
 
 logFilterHit ( $title, $url)
 Logs the filter hit to Special:Log if $wgLogSpamBlacklistHits is enabled.
 
 logUrlChanges ( $oldLinks, $newLinks, $addedLinks)
 Diff added/removed urls and generate events for them.
 
 warmCachesForFilter (Title $title, array $entries)
 
- Public Member Functions inherited from BaseBlacklist
 __construct ( $settings=[])
 Constructor.
 
 clearCache ()
 Clear all primary blacklist cache keys.
 
 filter (array $links, Title $title, $preventLog=false)
 
 getBlacklists ()
 Fetch local and (possibly cached) remote blacklists.
 
 getLocalBlacklists ()
 Returns the local blacklist.
 
 getWhitelists ()
 Returns the (local) whitelist.
 

Public Attributes

const STASH_AGE_DYING = 150
 
const STASH_TTL = 180
 
- Public Attributes inherited from BaseBlacklist
int $expiryTime = 900
 
array $files = []
 Array of blacklist sources.
 
int $warningChance = 100
 Chance of receiving a warning when the filter is hit.
 
int $warningTime = 600
 

Protected Member Functions

 antiSpoof ( $text)
 Apply some basic anti-spoofing to the links before they get filtered, see.
 
 getBlacklistType ()
 Returns the code for the blacklist implementation.
 

Private Member Functions

 logUrlChange ( $url, $action)
 Queue log data about change for a url addition or removal.
 

Private Attributes

array[] $urlChangeLog = []
 Changes to external links, for logging purposes.
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseBlacklist
static addBlacklistType ( $type, $class)
 Adds a blacklist class to the registry.
 
static getBlacklistTypes ()
 Return the array of blacklist types currently defined.
 
static getEmailBlacklist ()
 
static getInstance ( $type)
 Returns an instance of the given blacklist.
 
static getSpamBlacklist ()
 
static getTypeFromTitle (Title $title)
 Returns the type of blacklist from the given title.
 
static isLocalSource (Title $title)
 Check if the given local page title is a spam regex source.
 
- Protected Attributes inherited from BaseBlacklist
bool array $regexes = false
 Array containing regexes to test against.
 

Detailed Description

Definition at line 10 of file SpamBlacklist.php.

Member Function Documentation

◆ antiSpoof()

SpamBlacklist::antiSpoof ( $text)
protected

Apply some basic anti-spoofing to the links before they get filtered, see.

Bug
12896
Parameters
string$text
Returns
string

Definition at line 37 of file SpamBlacklist.php.

References and().

◆ doLogging()

SpamBlacklist::doLogging ( User $user,
Title $title,
$revId )

Actually push the url change events post-save.

Parameters
User$user
Title$title
int$revId

Definition at line 214 of file SpamBlacklist.php.

References $urlChangeLog, and isLoggingEnabled().

◆ filter()

SpamBlacklist::filter ( array $links,
Title $title = null,
$preventLog = false,
$mode = 'check' )
Parameters
string[]$linksAn array of links to check against the blacklist
Title | null$titleThe title of the page to which the filter shall be applied. This is used to load the old links already on the page, so the filter is only applied to links that got added. If not given, the filter is applied to all $links.
bool$preventLogWhether to prevent logging of hits. Set to true when the action is testing the links rather than attempting to save them (e.g. the API spamblacklist action)
string$modeEither 'check' or 'stash'
Returns
string[]|bool Matched text(s) if the edit should not be allowed; false otherwise

Definition at line 55 of file SpamBlacklist.php.

References $cache, $matches, $wgRequest, and(), BaseBlacklist\getBlacklists(), getBlacklistType(), getCurrentLinks(), BaseBlacklist\getWhitelists(), isLoggingEnabled(), logFilterHit(), logUrlChanges(), and wfDebugLog().

Referenced by warmCachesForFilter().

◆ getBlacklistType()

SpamBlacklist::getBlacklistType ( )
protected

Returns the code for the blacklist implementation.

Returns
string

Reimplemented from BaseBlacklist.

Definition at line 25 of file SpamBlacklist.php.

Referenced by filter().

◆ getCurrentLinks()

SpamBlacklist::getCurrentLinks ( Title $title)

Look up the links currently in the article, so we can ignore them on a second run.

WARNING: I can add more of the same link with no problem here.

Parameters
Title$title
Returns
array

Definition at line 273 of file SpamBlacklist.php.

References $cache, $dbr, $fname, and(), array(), DB_REPLICA, function, and wfGetDB().

Referenced by filter().

◆ getRegexEnd()

SpamBlacklist::getRegexEnd ( $batchSize)

Returns the end of the regex for matches.

Parameters
int$batchSize
Returns
string

Reimplemented from BaseBlacklist.

Definition at line 313 of file SpamBlacklist.php.

◆ getRegexStart()

SpamBlacklist::getRegexStart ( )

Returns the start of the regex for matches.

Returns
string

Reimplemented from BaseBlacklist.

Definition at line 303 of file SpamBlacklist.php.

◆ isLoggingEnabled()

SpamBlacklist::isLoggingEnabled ( )

Definition at line 179 of file SpamBlacklist.php.

References and(), and ExtensionRegistry\getInstance().

Referenced by doLogging(), filter(), and logUrlChanges().

◆ logFilterHit()

SpamBlacklist::logFilterHit ( $title,
$url )

Logs the filter hit to Special:Log if $wgLogSpamBlacklistHits is enabled.

Parameters
Title$title
string$urlURL that the user attempted to add

Definition at line 323 of file SpamBlacklist.php.

References and(), and ExtensionRegistry\getInstance().

Referenced by filter().

◆ logUrlChange()

SpamBlacklist::logUrlChange ( $url,
$action )
private

Queue log data about change for a url addition or removal.

Parameters
string$url
string$action'insert' or 'remove'

Definition at line 247 of file SpamBlacklist.php.

References and(), wfDebugLog(), and wfParseUrl().

Referenced by logUrlChanges().

◆ logUrlChanges()

SpamBlacklist::logUrlChanges ( $oldLinks,
$newLinks,
$addedLinks )

Diff added/removed urls and generate events for them.

Parameters
string[]$oldLinks
string[]$newLinks
string[]$addedLinks

Definition at line 192 of file SpamBlacklist.php.

References and(), isLoggingEnabled(), and logUrlChange().

Referenced by filter().

◆ warmCachesForFilter()

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

Reimplemented from BaseBlacklist.

Definition at line 294 of file SpamBlacklist.php.

References filter().

Member Data Documentation

◆ $urlChangeLog

array [] SpamBlacklist::$urlChangeLog = []
private

Changes to external links, for logging purposes.

Definition at line 18 of file SpamBlacklist.php.

Referenced by doLogging().

◆ STASH_AGE_DYING

const SpamBlacklist::STASH_AGE_DYING = 150

Definition at line 12 of file SpamBlacklist.php.

◆ STASH_TTL

const SpamBlacklist::STASH_TTL = 180

Definition at line 11 of file SpamBlacklist.php.


The documentation for this class was generated from the following file: