MediaWiki REL1_32
TitleBlacklist Class Reference

Implements a title blacklist for MediaWiki. More...

Collaboration diagram for TitleBlacklist:

Public Member Functions

 getBlacklist ()
 Get the current blacklist.
 
 getWhitelist ()
 Get the current whitelist.
 
 invalidate ()
 Invalidate the blacklist cache.
 
 isBlacklisted ( $title, $action='edit')
 Check whether the blacklist restricts performing a specific action on the given Title.
 
 isWhitelisted ( $title, $action='edit')
 Check whether it has been explicitly whitelisted that the current User may perform a specific action on the given Title.
 
 load ()
 Load all configured blacklist sources.
 
 loadWhitelist ()
 Load local whitelist.
 
 userCannot ( $title, $user, $action='edit', $override=true)
 Check whether the blacklist restricts given user performing a specific action on the given Title.
 
 validate ( $blacklist)
 Validate a new blacklist.
 

Static Public Member Functions

static destroySingleton ()
 Destroy/reset the current singleton instance.
 
static parseBlacklist ( $list, $sourceName)
 Parse blacklist from a string.
 
static singleton ()
 Get an instance of this class.
 
static userCanOverride ( $user, $action)
 Inidcates whether user can override blacklist on certain action.
 

Public Attributes

const VERSION = 3
 

Static Protected Attributes

static TitleBlacklist $instance = null
 

Static Private Member Functions

static getBlacklistText ( $source)
 Get the text of a blacklist from a specified source.
 
static getHttp ( $url)
 Get the text of a blacklist source via HTTP.
 

Private Attributes

array $mBlacklist = null
 
array $mWhitelist = null
 

Detailed Description

Implements a title blacklist for MediaWiki.

Definition at line 17 of file TitleBlacklist.php.

Member Function Documentation

◆ destroySingleton()

static TitleBlacklist::destroySingleton ( )
static

Destroy/reset the current singleton instance.

This is solely for testing and will fail unless MW_PHPUNIT_TEST is defined.

Definition at line 47 of file TitleBlacklist.php.

Referenced by ApiQueryTitleBlacklistTest\setUp(), and ApiQueryTitleBlacklistTest\tearDown().

◆ getBlacklist()

TitleBlacklist::getBlacklist ( )

Get the current blacklist.

Returns
TitleBlacklistEntry[]

Definition at line 262 of file TitleBlacklist.php.

References $mBlacklist, and load().

Referenced by isBlacklisted().

◆ getBlacklistText()

static TitleBlacklist::getBlacklistText ( $source)
staticprivate

Get the text of a blacklist from a specified source.

Parameters
array$sourceA blacklist source from $wgTitleBlacklistSources
Returns
string The content of the blacklist source as a string

Definition at line 115 of file TitleBlacklist.php.

References $source, getHttp(), and wfMessage().

Referenced by load().

◆ getHttp()

static TitleBlacklist::getHttp ( $url)
staticprivate

Get the text of a blacklist source via HTTP.

Parameters
string$urlURL of the blacklist source
Returns
string The content of the blacklist source as a string

Definition at line 287 of file TitleBlacklist.php.

References $messageMemc, $result, and Http\get().

Referenced by getBlacklistText().

◆ getWhitelist()

TitleBlacklist::getWhitelist ( )

Get the current whitelist.

Returns
Array of TitleBlacklistEntry items

Definition at line 274 of file TitleBlacklist.php.

References $mWhitelist, and loadWhitelist().

Referenced by isWhitelisted().

◆ invalidate()

TitleBlacklist::invalidate ( )

Invalidate the blacklist cache.

Definition at line 309 of file TitleBlacklist.php.

References $cache.

◆ isBlacklisted()

TitleBlacklist::isBlacklisted ( $title,
$action = 'edit' )

Check whether the blacklist restricts performing a specific action on the given Title.

Parameters
Title$titleTitle to check
string$actionAction to check; 'edit' if unspecified
Returns
TitleBlacklistEntry|bool The corresponding TitleBlacklistEntry if blacklisted; otherwise FALSE

Definition at line 208 of file TitleBlacklist.php.

References $params, getBlacklist(), and isWhitelisted().

Referenced by userCannot().

◆ isWhitelisted()

TitleBlacklist::isWhitelisted ( $title,
$action = 'edit' )

Check whether it has been explicitly whitelisted that the current User may perform a specific action on the given Title.

Parameters
Title$titleTitle to check
string$actionAction to check; 'edit' if unspecified
Returns
bool True if whitelisted; otherwise false

Definition at line 244 of file TitleBlacklist.php.

References getWhitelist().

Referenced by isBlacklisted().

◆ load()

TitleBlacklist::load ( )

Load all configured blacklist sources.

Definition at line 61 of file TitleBlacklist.php.

References $cache, $source, getBlacklistText(), parseBlacklist(), and wfDebugLog().

Referenced by getBlacklist().

◆ loadWhitelist()

TitleBlacklist::loadWhitelist ( )

Load local whitelist.

Definition at line 92 of file TitleBlacklist.php.

References $cache, parseBlacklist(), text, and wfMessage().

Referenced by getWhitelist().

◆ parseBlacklist()

static TitleBlacklist::parseBlacklist ( $list,
$sourceName )
static

Parse blacklist from a string.

Parameters
string$listText of a blacklist source
string$sourceName
Returns
array of TitleBlacklistEntry entries

Definition at line 160 of file TitleBlacklist.php.

References $line, $lines, $result, and TitleBlacklistEntry\newFromString().

Referenced by load(), and loadWhitelist().

◆ singleton()

◆ userCannot()

TitleBlacklist::userCannot ( $title,
$user,
$action = 'edit',
$override = true )

Check whether the blacklist restricts given user performing a specific action on the given Title.

Parameters
Title$titleTitle to check
User$userUser to check
string$actionAction to check; 'edit' if unspecified
bool$overrideIf set to true, overrides work
Returns
TitleBlacklistEntry|bool The corresponding TitleBlacklistEntry if blacklisted; otherwise false

Definition at line 184 of file TitleBlacklist.php.

References $params, and isBlacklisted().

◆ userCanOverride()

static TitleBlacklist::userCanOverride ( $user,
$action )
static

Inidcates whether user can override blacklist on certain action.

Parameters
User$user
string$actionAction
Returns
bool

Definition at line 342 of file TitleBlacklist.php.

Referenced by TitleBlacklistPreAuthenticationProvider\getAuthenticationRequests().

◆ validate()

TitleBlacklist::validate ( $blacklist)

Validate a new blacklist.

@suppress PhanParamSuspiciousOrder The preg_match() params are in the correct order

Parameters
array$blacklist
Returns
Array of bad entries; empty array means blacklist is valid

Definition at line 321 of file TitleBlacklist.php.

References $e, wfRestoreWarnings(), and wfSuppressWarnings().

Member Data Documentation

◆ $instance

TitleBlacklist TitleBlacklist::$instance = null
staticprotected

Definition at line 25 of file TitleBlacklist.php.

Referenced by singleton().

◆ $mBlacklist

array TitleBlacklist::$mBlacklist = null
private

Definition at line 19 of file TitleBlacklist.php.

Referenced by getBlacklist().

◆ $mWhitelist

array TitleBlacklist::$mWhitelist = null
private

Definition at line 22 of file TitleBlacklist.php.

Referenced by getWhitelist().

◆ VERSION

const TitleBlacklist::VERSION = 3

Definition at line 27 of file TitleBlacklist.php.

Referenced by TitleBlacklistEntry\__construct().


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