20use Wikimedia\Assert\Assert;
37 private static $counters = [
'edits',
'pages',
'articles',
'users',
'images' ];
42 $this->articles = $good;
49 Assert::parameterType( __CLASS__, $update,
'$update' );
51 foreach ( self::$counters
as $field ) {
52 $this->$field += $update->$field;
61 $update =
new self( 0, 0, 0 );
63 foreach ( self::$counters
as $field ) {
64 if ( isset( $deltas[$field] ) && $deltas[$field] ) {
65 $update->$field = $deltas[$field];
80 if ( $rate && ( $rate < 0 || mt_rand( 0, $rate - 1 ) != 0 ) ) {
84 DeferredUpdates::addCallableUpdate( [ $this,
'tryDBUpdateInternal' ] );
99 if ( !$dbw->lockIsFree( $lockKey, __METHOD__ )
100 || !$dbw->lock( $lockKey, __METHOD__, 1 )
108 $this->
edits += ( $pd[
'ss_total_edits'][
'+'] - $pd[
'ss_total_edits'][
'-'] );
109 $this->articles += ( $pd[
'ss_good_articles'][
'+'] - $pd[
'ss_good_articles'][
'-'] );
110 $this->
pages += ( $pd[
'ss_total_pages'][
'+'] - $pd[
'ss_total_pages'][
'-'] );
111 $this->users += ( $pd[
'ss_users'][
'+'] - $pd[
'ss_users'][
'-'] );
112 $this->images += ( $pd[
'ss_images'][
'+'] - $pd[
'ss_images'][
'-'] );
118 $this->
appendUpdate( $updates,
'ss_good_articles', $this->articles );
120 $this->
appendUpdate( $updates,
'ss_users', $this->users );
121 $this->
appendUpdate( $updates,
'ss_images', $this->images );
122 if ( $updates !=
'' ) {
123 $dbw->update(
'site_stats', [ $updates ], [], __METHOD__ );
130 $dbw->unlock( $lockKey, __METHOD__ );
144 # Get non-bot users than did some recent action other than making accounts.
145 # If account creation is included, the number gets inflated ~20+ fold on enwiki.
146 $activeUsers =
$dbr->selectField(
148 'COUNT( DISTINCT rc_user_text )',
152 'rc_log_type != ' .
$dbr->addQuotes(
'newusers' ) .
' OR rc_log_type IS NULL',
160 [
'ss_active_users' => intval( $activeUsers ) ],
161 [
'ss_row_id' => 1 ],
173 foreach ( [
'edits',
'articles',
'pages',
'users',
'images' ]
as $type ) {
174 $delta = $this->$type;
175 if ( $delta !== 0 ) {
176 $stats->updateCount(
"site.$type", $delta );
200 $sql .=
"$field=$field-" . abs( $delta );
202 $sql .=
"$field=$field+" . abs( $delta );
213 return wfMemcKey(
'sitestatsupdate',
'pendingdelta',
$type, $sign );
223 $cache = ObjectCache::getMainStashInstance();
230 $magnitude = abs( $delta );
231 $cache->incrWithInit( $key, 0, $magnitude, $magnitude );
239 $cache = ObjectCache::getMainStashInstance();
242 foreach ( [
'ss_total_edits',
243 'ss_good_articles',
'ss_total_pages',
'ss_users',
'ss_images' ]
as $type
246 $flg = BagOStuff::READ_LATEST;
247 $pending[
$type][
'+'] = (int)
$cache->get( $this->getTypeCacheKey(
$type,
'+' ), $flg );
248 $pending[
$type][
'-'] = (int)
$cache->get( $this->getTypeCacheKey(
$type,
'-' ), $flg );
259 $cache = ObjectCache::getMainStashInstance();
261 foreach ( $pd
as $type => $deltas ) {
262 foreach ( $deltas
as $sign => $magnitude ) {
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgActiveUserDays
How many days user must be idle before he is considered inactive.
$wgSiteStatsAsyncFactor
Set this to an integer to only do synchronous site_stats updates one every this many updates.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfMemcKey()
Make a cache key for the local wiki.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static getMain()
Static methods.
Class for handling updates to the site_stats table.
adjustPending( $type, $delta)
Adjust the pending deltas for a stat type.
static factory(array $deltas)
doUpdate()
Perform the actual work.
getPendingDeltas()
Get pending delta counters for each stat type.
tryDBUpdateInternal()
Do not call this outside of SiteStatsUpdate.
__construct( $views, $edits, $good, $pages=0, $users=0)
appendUpdate(&$sql, $field, $delta)
getTypeCacheKey( $type, $sign)
removePendingDeltas(array $pd)
Reduce pending delta counters after updates have been applied.
merge(MergeableUpdate $update)
Merge this update with $update.
static cacheUpdate( $dbw)
The ContentHandler facility adds support for arbitrary content types on wiki pages
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if so it s not worth the trouble Since there is a job queue in the jobs which is used to update link tables of transcluding pages after edits
when a variable name is used in a it is silently declared as a new local masking the global
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
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
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
Interface that deferrable updates should implement.
Interface that deferrable updates can implement.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.