MediaWiki REL1_34
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).
 
 sendPingback ()
 Send information about this MediaWiki instance to MediaWiki.org.
 

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.
 

Protected Attributes

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

Private Member Functions

 acquireLock ()
 Acquire lock for sending a pingback.
 
 checkIfSent ()
 Has a pingback been sent in the last month for this MediaWiki version?
 
 getData ()
 Get the EventLogging packet to be sent to the server.
 
 getOrCreatePingbackId ()
 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 to its event beacon endpoint.
 
 shouldSend ()
 Should a pingback be sent?
 

Detailed Description

Send information about this MediaWiki instance to MediaWiki.org.

Since
1.28

Definition at line 32 of file Pingback.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 57 of file Pingback.php.

References $config, and $logger.

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

References $cache, DB_MASTER, and wfGetDB().

Referenced by sendPingback().

◆ checkIfSent()

Pingback::checkIfSent ( )
private

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

Returns
bool

Definition at line 75 of file Pingback.php.

References $dbr, DB_REPLICA, and wfGetDB().

Referenced by shouldSend().

◆ getData()

Pingback::getData ( )
private

Get the EventLogging packet to be sent to the server.

Returns
array

Definition at line 170 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 187 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 143 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 97 of file Pingback.php.

References DB_MASTER, 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 229 of file Pingback.php.

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

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

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

◆ shouldSend()

Pingback::shouldSend ( )
private

Should a pingback be sent?

Returns
bool

Definition at line 67 of file Pingback.php.

References checkIfSent().

Member Data Documentation

◆ $config

Config Pingback::$config
protected

Definition at line 45 of file Pingback.php.

Referenced by __construct().

◆ $id

string Pingback::$id
protected

Randomly-generated identifier for this wiki.

Definition at line 51 of file Pingback.php.

Referenced by getOrCreatePingbackId().

◆ $key

string Pingback::$key
protected

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

Definition at line 48 of file Pingback.php.

◆ $logger

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

Definition at line 42 of file Pingback.php.

Referenced by __construct().


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