MediaWiki REL1_37
Pingback Class Reference

Send information about this MediaWiki instance to mediawiki.org. More...

Collaboration diagram for Pingback:

Public Member Functions

 __construct (Config $config, ILoadBalancer $lb, BagOStuff $cache, HttpRequestFactory $http, LoggerInterface $logger)
 
 run ()
 Maybe send a ping.
 

Static Public Member Functions

static getSystemInfo (Config $config)
 Collect basic data about this MediaWiki installation and return it as an associative array conforming to the Pingback schema on Meta-Wiki (https://meta.wikimedia.org/wiki/Schema:MediaWikiPingback).
 
static schedulePingback ()
 Schedule a deferred callable that will check if a pingback should be sent and (if so) proceed to send it.
 

Protected Member Functions

 getData ()
 Get the EventLogging packet to be sent to the server.
 

Protected Attributes

BagOStuff $cache
 
Config $config
 
HttpRequestFactory $http
 
string $key
 updatelog key (also used as cache/db lock key)
 
ILoadBalancer $lb
 
LoggerInterface $logger
 

Private Member Functions

 acquireLock ()
 Acquire lock for sending a pingback.
 
 fetchOrInsertId ()
 Get a unique, stable identifier for this wiki.
 
 markSent ()
 Record the fact that we have sent a pingback for this MediaWiki version, to ensure we don't submit data multiple times.
 
 postPingback (array $data)
 Serialize pingback data and send it to mediawiki.org via a POST request to its EventLogging beacon endpoint.
 
 wasRecentlySent ()
 Was a pingback sent in the last month for this MediaWiki version?
 

Detailed Description

Send information about this MediaWiki instance to mediawiki.org.

This service uses two kinds of rows in the update_log database table:

  • ul_key PingBack, this holds a random identifier for this wiki, created only once, when the first ping after wiki creation is sent.
  • ul_key Pingback-<MW_VERSION>, this holds a timestamp and is created once after each MediaWiki upgrade, and then updated up to once a month.
Access: internal
For use by Setup.php only
Since
1.28

Definition at line 44 of file Pingback.php.

Constructor & Destructor Documentation

◆ __construct()

Pingback::__construct ( Config  $config,
ILoadBalancer  $lb,
BagOStuff  $cache,
HttpRequestFactory  $http,
LoggerInterface  $logger 
)
Parameters
Config$config
ILoadBalancer$lb
BagOStuff$cache
HttpRequestFactory$http
LoggerInterface$logger

Definition at line 71 of file Pingback.php.

References $cache, $config, $http, $lb, $logger, and MW_VERSION.

Member Function Documentation

◆ acquireLock()

Pingback::acquireLock ( )
private

Acquire lock for sending a pingback.

This ensures only one thread can attempt to send a pingback at any given time and that we wait an hour before retrying failed attempts.

Returns
bool Whether lock was acquired

Definition at line 147 of file Pingback.php.

◆ fetchOrInsertId()

Pingback::fetchOrInsertId ( )
private

Get a unique, stable identifier for this wiki.

If the identifier does not already exist, create it and save it in the database. The identifier is randomly-generated.

Exceptions
DBErrorIf identifier insert fails
Returns
string 32-character hex string

Definition at line 221 of file Pingback.php.

◆ getData()

Pingback::getData ( )
protected

Get the EventLogging packet to be sent to the server.

Exceptions
DBErrorIf identifier insert fails
Returns
array

Definition at line 169 of file Pingback.php.

◆ getSystemInfo()

static Pingback::getSystemInfo ( Config  $config)
static

Collect basic data about this MediaWiki installation and return it as an associative array conforming to the Pingback schema on Meta-Wiki (https://meta.wikimedia.org/wiki/Schema:MediaWikiPingback).

Developers: If you're adding a new piece of data to this, please document this data at https://www.mediawiki.org/wiki/Manual:$wgPingback.

Access: internal
For use by Installer only to display which data we send.
Parameters
Config$configWith DBtype set.
Returns
array

Definition at line 190 of file Pingback.php.

Referenced by WebInstallerName\execute().

◆ markSent()

Pingback::markSent ( )
private

Record the fact that we have sent a pingback for this MediaWiki version, to ensure we don't submit data multiple times.

Exceptions
DBErrorIf timestamp upsert fails

Definition at line 274 of file Pingback.php.

◆ postPingback()

Pingback::postPingback ( array  $data)
private

Serialize pingback data and send it to mediawiki.org via a POST request to its EventLogging beacon endpoint.

The data encoding conforms to the expectations of EventLogging as used by Wikimedia Foundation for logging and processing analytic data.

Compare: https://gerrit.wikimedia.org/g/mediawiki/extensions/EventLogging/+/7e5fe4f1ef/includes/EventLogging.php#L32

The schema for the data is located at: https://meta.wikimedia.org/wiki/Schema:MediaWikiPingback

Parameters
array$dataPingback data as an associative array
Returns
bool

Definition at line 261 of file Pingback.php.

◆ run()

Pingback::run ( )

Maybe send a ping.

Exceptions
DBErrorIf identifier insert fails
DBErrorIf timestamp upsert fails

Definition at line 92 of file Pingback.php.

◆ schedulePingback()

static Pingback::schedulePingback ( )
static

Schedule a deferred callable that will check if a pingback should be sent and (if so) proceed to send it.

Definition at line 290 of file Pingback.php.

◆ wasRecentlySent()

Pingback::wasRecentlySent ( )
private

Was a pingback sent in the last month for this MediaWiki version?

Returns
bool

Definition at line 121 of file Pingback.php.

Member Data Documentation

◆ $cache

BagOStuff Pingback::$cache
protected

Definition at line 58 of file Pingback.php.

Referenced by __construct().

◆ $config

Config Pingback::$config
protected

Definition at line 54 of file Pingback.php.

Referenced by __construct().

◆ $http

HttpRequestFactory Pingback::$http
protected

Definition at line 60 of file Pingback.php.

Referenced by __construct().

◆ $key

string Pingback::$key
protected

updatelog key (also used as cache/db lock key)

Definition at line 62 of file Pingback.php.

◆ $lb

ILoadBalancer Pingback::$lb
protected

Definition at line 56 of file Pingback.php.

Referenced by __construct().

◆ $logger

LoggerInterface Pingback::$logger
protected
Initial value:
=
private const SCHEMA_REV 15781718

Definition at line 52 of file Pingback.php.

Referenced by __construct().


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