MediaWiki  1.28.0
SiteStatsUpdate Class Reference

Class for handling updates to the site_stats table. More...

Inheritance diagram for SiteStatsUpdate:
Collaboration diagram for SiteStatsUpdate:

Public Member Functions

 __construct ($views, $edits, $good, $pages=0, $users=0)
 
 doUpdate ()
 Perform the actual work. More...
 
 merge (MergeableUpdate $update)
 Merge this update with $update. More...
 
 tryDBUpdateInternal ()
 Do not call this outside of SiteStatsUpdate. More...
 

Static Public Member Functions

static cacheUpdate ($dbw)
 
static factory (array $deltas)
 

Protected Member Functions

 adjustPending ($type, $delta)
 Adjust the pending deltas for a stat type. More...
 
 appendUpdate (&$sql, $field, $delta)
 
 doUpdateContextStats ()
 
 doUpdatePendingDeltas ()
 
 getPendingDeltas ()
 Get pending delta counters for each stat type. More...
 
 removePendingDeltas (array $pd)
 Reduce pending delta counters after updates have been applied. More...
 

Protected Attributes

int $articles = 0
 
int $edits = 0
 
int $images = 0
 
int $pages = 0
 
int $users = 0
 

Private Member Functions

 getTypeCacheKey ($type, $sign)
 

Static Private Attributes

static $counters = [ 'edits', 'pages', 'articles', 'users', 'images' ]
 

Detailed Description

Class for handling updates to the site_stats table.

Definition at line 25 of file SiteStatsUpdate.php.

Constructor & Destructor Documentation

SiteStatsUpdate::__construct (   $views,
  $edits,
  $good,
  $pages = 0,
  $users = 0 
)

Definition at line 40 of file SiteStatsUpdate.php.

References $edits, $pages, $users, edits, and pages.

Member Function Documentation

SiteStatsUpdate::adjustPending (   $type,
  $delta 
)
protected

Adjust the pending deltas for a stat type.

Each stat type has two pending counters, one for increments and decrements

Parameters
string$type
int$deltaDelta (positive or negative)

Definition at line 222 of file SiteStatsUpdate.php.

References $cache, $type, ObjectCache\getMainStashInstance(), and getTypeCacheKey().

Referenced by doUpdatePendingDeltas().

SiteStatsUpdate::appendUpdate ( $sql,
  $field,
  $delta 
)
protected
Parameters
string$sql
string$field
int$delta

Definition at line 194 of file SiteStatsUpdate.php.

Referenced by tryDBUpdateInternal().

static SiteStatsUpdate::cacheUpdate (   $dbw)
static
Parameters
IDatabase$dbw
Returns
bool|mixed

Definition at line 141 of file SiteStatsUpdate.php.

References $dbr, DB_REPLICA, global, TS_UNIX, SiteStats\unload(), wfGetDB(), and wfTimestamp().

Referenced by SiteStatsInit\doAllAndCommit(), and InitSiteStats\execute().

SiteStatsUpdate::doUpdate ( )

Perform the actual work.

Implements DeferrableUpdate.

Definition at line 72 of file SiteStatsUpdate.php.

References DeferredUpdates\addCallableUpdate(), doUpdateContextStats(), doUpdatePendingDeltas(), and global.

SiteStatsUpdate::doUpdateContextStats ( )
protected

Definition at line 171 of file SiteStatsUpdate.php.

References $type, as, and RequestContext\getMain().

Referenced by doUpdate().

SiteStatsUpdate::doUpdatePendingDeltas ( )
protected

Definition at line 181 of file SiteStatsUpdate.php.

References adjustPending(), edits, and pages.

Referenced by doUpdate(), and tryDBUpdateInternal().

static SiteStatsUpdate::factory ( array  $deltas)
static
Parameters
array$deltas
Returns
SiteStatsUpdate

Definition at line 60 of file SiteStatsUpdate.php.

References as.

Referenced by LocalFile\delete(), LocalFileRestoreBatch\execute(), WikiImporter\finishImportPage(), and LocalFile\recordUpload2().

SiteStatsUpdate::getPendingDeltas ( )
protected

Get pending delta counters for each stat type.

Returns
array Positive and negative deltas for each type

Definition at line 238 of file SiteStatsUpdate.php.

References $cache, $type, as, ObjectCache\getMainStashInstance(), and BagOStuff\READ_LATEST.

Referenced by tryDBUpdateInternal().

SiteStatsUpdate::getTypeCacheKey (   $type,
  $sign 
)
private
Parameters
string$type
string$sign('+' or '-')
Returns
string

Definition at line 212 of file SiteStatsUpdate.php.

References $type, and wfMemcKey().

Referenced by adjustPending(), and removePendingDeltas().

SiteStatsUpdate::merge ( MergeableUpdate  $update)

Merge this update with $update.

Parameters
MergeableUpdate$updateUpdate of the same class type

Implements MergeableUpdate.

Definition at line 47 of file SiteStatsUpdate.php.

References as.

SiteStatsUpdate::removePendingDeltas ( array  $pd)
protected

Reduce pending delta counters after updates have been applied.

Parameters
array$pdResult of getPendingDeltas(), used for DB update

Definition at line 258 of file SiteStatsUpdate.php.

References $cache, $type, as, ObjectCache\getMainStashInstance(), and getTypeCacheKey().

Referenced by tryDBUpdateInternal().

SiteStatsUpdate::tryDBUpdateInternal ( )

Member Data Documentation

int SiteStatsUpdate::$articles = 0
protected

Definition at line 31 of file SiteStatsUpdate.php.

SiteStatsUpdate::$counters = [ 'edits', 'pages', 'articles', 'users', 'images' ]
staticprivate

Definition at line 37 of file SiteStatsUpdate.php.

int SiteStatsUpdate::$edits = 0
protected

Definition at line 27 of file SiteStatsUpdate.php.

Referenced by __construct().

int SiteStatsUpdate::$images = 0
protected

Definition at line 35 of file SiteStatsUpdate.php.

int SiteStatsUpdate::$pages = 0
protected

Definition at line 29 of file SiteStatsUpdate.php.

Referenced by __construct().

int SiteStatsUpdate::$users = 0
protected

Definition at line 33 of file SiteStatsUpdate.php.

Referenced by __construct().


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