MediaWiki  1.30.2
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. More...
 
 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. More...
 
 getRegexEnd ( $batchSize)
 Returns the end of the regex for matches. More...
 
 getRegexStart ()
 Returns the start of the regex for matches. More...
 
 isLoggingEnabled ()
 
 logFilterHit ( $title, $url)
 Logs the filter hit to Special:Log if $wgLogSpamBlacklistHits is enabled. More...
 
 logUrlChanges ( $oldLinks, $newLinks, $addedLinks)
 Diff added/removed urls and generate events for them. More...
 
 warmCachesForFilter (Title $title, array $entries)
 
- Public Member Functions inherited from BaseBlacklist
 __construct ( $settings=[])
 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...
 
 getSharedBlacklists ()
 Fetch (possibly cached) remote blacklists. More...
 
 getWhitelists ()
 Returns the (local) whitelist. More...
 

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. More...
 
int $warningChance = 100
 Chance of receiving a warning when the filter is hit. More...
 
int $warningTime = 600
 

Protected Member Functions

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

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from BaseBlacklist
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...
 
- Protected Attributes inherited from BaseBlacklist
bool array $regexes = false
 Array containing regexes to test against. More...
 

Detailed Description

Definition at line 9 of file SpamBlacklist_body.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 36 of file SpamBlacklist_body.php.

◆ 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 212 of file SpamBlacklist_body.php.

References $title, $urlChangeLog, $user, DeferredUpdates\addCallableUpdate(), as, isLoggingEnabled(), and use.

◆ filter()

SpamBlacklist::filter ( array  $links,
Title  $title = null,
  $preventLog = false,
  $mode = 'check' 
)
Parameters
string[]$linksAn array of links to check against the blacklist
Title$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 54 of file SpamBlacklist_body.php.

References $cache, $matches, $title, $wgRequest, as, captcha-old\count, BaseBlacklist\getBlacklists(), getBlacklistType(), getCurrentLinks(), ObjectCache\getLocalClusterInstance(), BaseBlacklist\getWhitelists(), global, isLoggingEnabled(), logFilterHit(), logUrlChanges(), wfDebugLog(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by warmCachesForFilter().

◆ getBlacklistType()

SpamBlacklist::getBlacklistType ( )
protected

Returns the code for the blacklist implementation.

Returns
string

Reimplemented from BaseBlacklist.

Definition at line 24 of file SpamBlacklist_body.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
$titleTitle
Returns
array

Definition at line 271 of file SpamBlacklist_body.php.

References $cache, $dbr, $title, array(), DB_SLAVE, ObjectCache\getMainWANInstance(), use, and wfGetDB().

Referenced by filter().

◆ getRegexEnd()

SpamBlacklist::getRegexEnd (   $batchSize)

Returns the end of the regex for matches.

Parameters
$batchSize
Returns
string

Reimplemented from BaseBlacklist.

Definition at line 310 of file SpamBlacklist_body.php.

◆ getRegexStart()

SpamBlacklist::getRegexStart ( )

Returns the start of the regex for matches.

Returns
string

Reimplemented from BaseBlacklist.

Definition at line 300 of file SpamBlacklist_body.php.

◆ isLoggingEnabled()

SpamBlacklist::isLoggingEnabled ( )

Definition at line 178 of file SpamBlacklist_body.php.

References global.

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 320 of file SpamBlacklist_body.php.

References $title, $wgUser, ExtensionRegistry\getInstance(), and global.

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 245 of file SpamBlacklist_body.php.

References 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 190 of file SpamBlacklist_body.php.

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

Referenced by filter().

◆ warmCachesForFilter()

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

Reimplemented from BaseBlacklist.

Definition at line 291 of file SpamBlacklist_body.php.

References $title, and filter().

Member Data Documentation

◆ $urlChangeLog

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

Changes to external links, for logging purposes.

Definition at line 17 of file SpamBlacklist_body.php.

Referenced by doLogging().

◆ STASH_AGE_DYING

const SpamBlacklist::STASH_AGE_DYING = 150

Definition at line 11 of file SpamBlacklist_body.php.

◆ STASH_TTL

const SpamBlacklist::STASH_TTL = 180

Definition at line 10 of file SpamBlacklist_body.php.


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