27use Psr\Log\LoggerAwareInterface;
28use 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 ) ) );
73 $conditions = $config->get(
'PasswordAttemptThrottle' );
76 'cache' => \ObjectCache::getLocalClusterInstance(),
82 'cache' => \ObjectCache::getLocalClusterInstance(),
83 'warningLimit' => INF,
90 $this->warningLimit =
$params[
'warningLimit'];
92 $this->
setLogger( LoggerFactory::getInstance(
'throttler' ) );
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 {ipKey}';
200 $level =
$context[
'count'] >= $this->warningLimit ? LogLevel::WARNING : LogLevel::INFO;
205 $this->logger->log( $level, $logMsg,
$context );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable or merely the Work and Derivative Works thereof Contribution shall mean any work of including the original version of the Work and any modifications or additions to that Work or Derivative Works that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this submitted means any form of or written communication sent to the Licensor or its including but not limited to communication on electronic mailing source code control and issue tracking systems that are managed or on behalf the Licensor for the purpose of discussing and improving the but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as Not a Contribution Contributor shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work Grant of Copyright License Subject to the terms and conditions of this each Contributor hereby grants to You a non no royalty irrevocable copyright license to prepare Derivative Works publicly publicly and distribute the Work and such Derivative Works in Source or Object form Grant of Patent License Subject to the terms and conditions of this each Contributor hereby grants to You a non no royalty have offer to and otherwise transfer the where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed Redistribution You may reproduce and distribute copies of the Work or Derivative Works thereof in any with or without and in Source or Object provided that You meet the following conditions
to add to the query
Class representing a cache/ephemeral data store.
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
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
this hook is for auditing only or null if authentication failed before getting that far $username
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
you have access to all of the normal MediaWiki so you can get a DB use the cache
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))
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 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