44 'spam' =>
'SpamBlacklist',
45 'email' =>
'EmailBlacklist',
61 foreach ( $settings as $name =>
$value ) {
81 self::$blacklistTypes[
$type] = $class;
116 if ( !
isset( self::$blacklistTypes[
$type] ) ) {
117 throw new Exception(
"Invalid blacklist type '$type' passed to " . __METHOD__ );
124 if ( !
isset( $wgBlacklistSettings[
$type] ) ) {
125 $wgBlacklistSettings[
$type] = [];
128 $class = self::$blacklistTypes[
$type];
129 self::$instances[
$type] =
new $class( $wgBlacklistSettings[
$type] );
132 return self::$instances[
$type];
151 if ( $title->getNamespace() == NS_MEDIAWIKI ) {
153 foreach ( self::$blacklistTypes as
$type => $class ) {
161 if (
in_array( $title->getDBkey(), $sources ) ) {
167 $thisHttpRegex =
'/^' .
preg_quote( $thisHttp,
'/' ) .
'(?:&.*)?$/';
170 foreach ( self::$blacklistTypes as
$type => $class ) {
171 if (
isset( $wgBlacklistSettings[
$type][
'files'] ) ) {
177 foreach (
$files as $fileName ) {
181 if (
$matches[2] == $title->getPrefixedDbKey() ) {
206 $regex =
'/(' . implode(
'|', $types ) .
')-(?:blacklist|whitelist)/';
208 if (
preg_match( $regex, $title->getDBkey(), $m ) ) {
221 if ( $this->regexes ===
false ) {
237 $cache = ObjectCache::getMainWANInstance();
239 return $cache->getWithSetCallback(
240 $cache->makeKey(
'spamblacklist',
$type,
'blacklist-regex' ),
256 $cache = ObjectCache::getMainWANInstance();
258 return $cache->getWithSetCallback(
259 $cache->makeKey(
'spamblacklist',
$type,
'whitelist-regex' ),
274 wfDebugLog(
'SpamBlacklist',
"Loading $listType regex..." );
276 if ( count( $this->
files ) == 0 ) {
278 wfDebugLog(
'SpamBlacklist',
"no files specified\n" );
285 $cache = ObjectCache::getMainWANInstance();
289 $cache->makeKey(
'spamblacklist', $listType,
'shared-blacklist-regex' ),
293 return $that->buildSharedBlacklists();
298 wfDebugLog(
'SpamBlacklist',
"Got shared spam regexes from cache\n" );
312 $cache = ObjectCache::getMainWANInstance();
313 $cache->delete(
$cache->makeKey(
'spamblacklist', $listType,
'shared-blacklist-regex' ) );
314 $cache->delete(
$cache->makeKey(
'spamblacklist', $listType,
'blacklist-regex' ) );
315 $cache->delete(
$cache->makeKey(
'spamblacklist', $listType,
'whitelist-regex' ) );
317 wfDebugLog(
'SpamBlacklist',
"$listType blacklist local cache cleared.\n" );
324 wfDebugLog(
'SpamBlacklist',
"Constructing $listType blacklist\n" );
325 foreach ( $this->
files as $fileName ) {
333 wfDebugLog(
'SpamBlacklist',
"got from file $fileName\n" );
353 # To keep requests to a minimum, we save results into $messageMemc, which is
354 # similar to $wgMemc except almost certain to exist. By default, it is stored
356 # There are two keys, when the warning key expires, a random thread will refresh
357 # the real key. This reduces the chance of multiple requests under high traffic
359 $key =
"{$listType}_blacklist_file:$fileName";
360 $warningKey =
"$wgDBname:{$listType}filewarning:$fileName";
364 if ( !
is_string( $httpText ) || ( !$warning && !
mt_rand( 0, $this->warningChance ) ) ) {
365 wfDebugLog(
'SpamBlacklist',
"Loading $listType blacklist from $fileName\n" );
367 if ( $httpText ===
false ) {
368 wfDebugLog(
'SpamBlacklist',
"Error loading $listType blacklist from $fileName\n" );
370 $messageMemc->set( $warningKey, 1, $this->warningTime );
371 $messageMemc->set( $key, $httpText, $this->expiryTime );
373 wfDebugLog(
'SpamBlacklist',
"Got $listType blacklist from HTTP cache for $fileName\n" );
388 "Fetching {$this->getBlacklistType()} blacklist from '$article' on '$wiki'...\n" );
390 $title = Title::newFromText(
$article );
394 if (
is_callable( [ Revision::class,
'getQueryInfo' ] ) ) {
398 'tables' => [
'revision',
'page',
'text' ],
405 'text' => [
'JOIN',
'old_id=rev_text_id' ]
413 'page_namespace' => $title->getNamespace(),
414 'page_title' => $title->getDBkey(),
418 [
'page' => [
'JOIN',
'rev_id=page_latest' ] ] +
$revQuery[
'joins']
432 return '/[a-z0-9_\-.]*';
442 return ( $batchSize > 0 ) ?
'/Sim' :
'/im';
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition files
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Base class for different kinds of blacklists.
static array $blacklistTypes
Array containing blacklists that extend BaseBlacklist.
getLocalBlacklists()
Returns the local blacklist.
static getBlacklistTypes()
Return the array of blacklist types currently defined.
array $files
Array of blacklist sources.
static getEmailBlacklist()
__construct( $settings=[])
Constructor.
static getSpamBlacklist()
getBlacklists()
Fetch local and (possibly cached) remote blacklists.
clearCache()
Clear all primary blacklist cache keys.
filter(array $links, Title $title, $preventLog=false)
getWhitelists()
Returns the (local) whitelist.
getSharedBlacklists()
Fetch (possibly cached) remote blacklists.
getBlacklistType()
Returns the code for the blacklist implementation.
getRegexStart()
Returns the start of the regex for matches.
static getInstance( $type)
Returns an instance of the given blacklist.
getArticleText( $wiki, $article)
Fetch an article from this or another local MediaWiki database.
static getTypeFromTitle(Title $title)
Returns the type of blacklist from the given title.
bool array $regexes
Array containing regexes to test against.
static isLocalSource(Title $title)
Check if the given local page title is a spam regex source.
static array $instances
Array of blacklist instances.
static addBlacklistType( $type, $class)
Adds a blacklist class to the registry.
int $warningChance
Chance of receiving a warning when the filter is hit.
getRegexEnd( $batchSize)
Returns the end of the regex for matches.
warmCachesForFilter(Title $title, array $entries)
static get( $url, array $options=[], $caller=__METHOD__)
Simple wrapper for Http::request( 'GET' )
static selectTextFields()
Return the list of text fields that should be selected to read the revision text.
static selectPageFields()
Return the list of page fields that should be selected from page table.
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
static regexesFromMessage( $message, BaseBlacklist $blacklist)
Build a set of regular expressions from a MediaWiki message.
static regexesFromText( $source, BaseBlacklist $blacklist, $fileName=false)
Build a set of regular expressions from the given multiline input text, with empty lines and comments...
Represents a title within MediaWiki.
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used the name of the old file & $article
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback function
controlled by the following MediaWiki still creates a BagOStuff but calls it to it are no ops If the cache daemon can t be it should also disable itself fairly $wgDBname
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))