MediaWiki  1.30.0
Pingback Class Reference

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

Collaboration diagram for Pingback:

Public Member Functions

 __construct (Config $config=null, LoggerInterface $logger=null)
 
 getSystemInfo ()
 Collect basic data about this MediaWiki installation and return it as an associative array conforming to the Pingback schema on MetaWiki (https://meta.wikimedia.org/wiki/Schema:MediaWikiPingback). More...
 
 sendPingback ()
 Send information about this MediaWiki instance to MediaWiki.org. More...
 

Static Public Member Functions

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

Protected Attributes

Config $config
 
string $id
 Randomly-generated identifier for this wiki. More...
 
string $key
 updatelog key (also used as cache/db lock key) More...
 
LoggerInterface $logger
 

Private Member Functions

 acquireLock ()
 Acquire lock for sending a pingback. More...
 
 checkIfSent ()
 Has a pingback already been sent for this MediaWiki version? More...
 
 getData ()
 Get the EventLogging packet to be sent to the server. More...
 
 getOrCreatePingbackId ()
 Get a unique, stable identifier for this wiki. More...
 
 markSent ()
 Record the fact that we have sent a pingback for this MediaWiki version, to ensure we don't submit data multiple times. More...
 
 postPingback (array $data)
 Serialize pingback data and send it to MediaWiki.org via a POST to its event beacon endpoint. More...
 
 shouldSend ()
 Should a pingback be sent? More...
 

Detailed Description

Send information about this MediaWiki instance to MediaWiki.org.

Since
1.28

Definition at line 31 of file Pingback.php.

Constructor & Destructor Documentation

◆ __construct()

Pingback::__construct ( Config  $config = null,
LoggerInterface  $logger = null 
)
Parameters
Config$config
LoggerInterface$logger

Definition at line 56 of file Pingback.php.

References $config, $logger, RequestContext\getMain(), and key.

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 99 of file Pingback.php.

References $cache, DB_MASTER, ObjectCache\getLocalClusterInstance(), and wfGetDB().

Referenced by sendPingback().

◆ checkIfSent()

Pingback::checkIfSent ( )
private

Has a pingback already been sent for this MediaWiki version?

Returns
bool

Definition at line 74 of file Pingback.php.

References $dbr, DB_REPLICA, key, and wfGetDB().

Referenced by shouldSend().

◆ getData()

Pingback::getData ( )
private

Get the EventLogging packet to be sent to the server.

Returns
array

Definition at line 152 of file Pingback.php.

References getOrCreatePingbackId(), and getSystemInfo().

Referenced by sendPingback().

◆ getOrCreatePingbackId()

Pingback::getOrCreatePingbackId ( )
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.

Returns
string 32-character hex string

Definition at line 169 of file Pingback.php.

References $id, DB_MASTER, DB_REPLICA, MWCryptRand\generateHex(), and wfGetDB().

Referenced by getData().

◆ getSystemInfo()

Pingback::getSystemInfo ( )

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

This is public so we can display it in the installer

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

Returns
array

Definition at line 125 of file Pingback.php.

Referenced by getData().

◆ 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.

Definition at line 85 of file Pingback.php.

References DB_MASTER, key, and wfGetDB().

Referenced by sendPingback().

◆ postPingback()

Pingback::postPingback ( array  $data)
private

Serialize pingback data and send it to MediaWiki.org via a POST to its event beacon endpoint.

The data encoding conforms to the expectations of EventLogging, a software suite used by the Wikimedia Foundation for logging and processing analytic data.

Compare: <https://github.com/wikimedia/mediawiki-extensions-EventLogging/ blob/7e5fe4f1ef/includes/EventLogging.php#L32-L74>

Parameters
array$dataPingback data as an associative array
Returns
bool true on success, false on failure

Definition at line 211 of file Pingback.php.

References FormatJson\encode(), and Http\post().

Referenced by sendPingback().

◆ 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 254 of file Pingback.php.

References DeferredUpdates\addCallableUpdate(), and sendPingback().

◆ sendPingback()

Pingback::sendPingback ( )

Send information about this MediaWiki instance to MediaWiki.org.

The data is structured and serialized to match the expectations of EventLogging, a software suite used by the Wikimedia Foundation for logging and processing analytic data.

Compare: <https://github.com/wikimedia/mediawiki-extensions-EventLogging/ blob/7e5fe4f1ef/includes/EventLogging.php#L32-L74>

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

Returns
bool

Definition at line 233 of file Pingback.php.

References acquireLock(), getData(), markSent(), and postPingback().

Referenced by schedulePingback().

◆ shouldSend()

Pingback::shouldSend ( )
private

Should a pingback be sent?

Returns
bool

Definition at line 66 of file Pingback.php.

References checkIfSent().

Member Data Documentation

◆ $config

Config Pingback::$config
protected

Definition at line 44 of file Pingback.php.

Referenced by __construct().

◆ $id

string Pingback::$id
protected

Randomly-generated identifier for this wiki.

Definition at line 50 of file Pingback.php.

Referenced by getOrCreatePingbackId().

◆ $key

string Pingback::$key
protected

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

Definition at line 47 of file Pingback.php.

◆ $logger

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

Definition at line 33 of file Pingback.php.

Referenced by __construct().


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