Go to the documentation of this file.
27 use Psr\Log\LoggerAwareInterface;
28 use Psr\Log\LoggerInterface;
64 $invalidParams = array_diff_key(
$params,
65 array_fill_keys( [
'type',
'cache',
'warningLimit' ],
true ) );
66 if ( $invalidParams ) {
67 throw new \InvalidArgumentException(
'unrecognized parameters: '
68 . implode(
', ', array_keys( $invalidParams ) ) );
83 'warningLimit' => INF,
90 $this->warningLimit =
$params[
'warningLimit'];
114 if (
$username ===
null && $ip ===
null ) {
115 throw new \InvalidArgumentException(
'Either username or IP must be set for throttling' );
119 foreach ( $this->
conditions as $index => $throttleCondition ) {
120 $ipKey = isset( $throttleCondition[
'allIPs'] ) ? null : $ip;
121 $count = $throttleCondition[
'count'];
122 $expiry = $throttleCondition[
'seconds'];
126 if ( !$count || $userKey ===
null && $ipKey ===
null ) {
130 $throttleKey = $this->
cache->makeGlobalKey(
'throttler', $this->
type, $index, $ipKey, $userKey );
131 $throttleCount = $this->
cache->get( $throttleKey );
133 if ( !$throttleCount ) {
134 $this->
cache->add( $throttleKey, 1, $expiry );
135 } elseif ( $throttleCount < $count ) {
136 $this->
cache->incr( $throttleKey );
139 'throttle' => $this->
type,
146 'method' => $caller ?: __METHOD__,
151 'throttleIndex' => $index,
171 foreach ( $this->
conditions as $index => $specificThrottle ) {
172 $ipKey = isset( $specificThrottle[
'allIPs'] ) ? null : $ip;
173 $throttleKey = $this->
cache->makeGlobalKey(
'throttler', $this->
type, $index, $ipKey, $userKey );
174 $this->
cache->delete( $throttleKey );
185 if ( !is_array( $throttleConditions ) ) {
188 if ( isset( $throttleConditions[
'count'] ) ) {
189 $throttleConditions = [ $throttleConditions ];
191 return $throttleConditions;
195 $logMsg =
'Throttle {throttle} hit, throttled for {expiry} seconds due to {count} attempts '
196 .
'from username {username} and IP {ip}';
200 $level =
$context[
'count'] >= $this->warningLimit ? LogLevel::WARNING : LogLevel::INFO;
205 $this->logger->log( $level, $logMsg,
$context );
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
static getLocalClusterInstance()
Get the main cluster-local cache object.
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Program or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these conditions
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
interface is intended to be more or less compatible with the PHP memcached client.
you have access to all of the normal MediaWiki so you can get a DB use the cache
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 the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method. MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances. The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An SPI is an API intended to be implemented or extended by a third party. This software design pattern is intended to enable framework extension and replaceable components. It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki. The service provider interface allows the backend logging library to be implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime. This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance. Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
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 MediaWikiServices
this hook is for auditing only or null if authentication failed before getting that far $username
the array() calling protocol came about after MediaWiki 1.4rc1.