Go to the documentation of this file.
23 use Psr\Log\LoggerInterface;
39 const SCHEMA_REV = 15781718;
59 $this->logger =
$logger ?: LoggerFactory::getInstance( __CLASS__ );
60 $this->key =
'Pingback-' . $this->config->get(
'Version' );
68 return $this->config->get(
'Pingback' ) && !$this->
checkIfSent();
77 $timestamp =
$dbr->selectField(
80 [
'ul_key' => $this->key ],
83 if ( $timestamp ===
false ) {
87 if ( time() - (
int)$timestamp > 60 * 60 * 24 * 30 ) {
102 [
'ul_key' => $this->key,
'ul_value' => $timestamp ],
104 [
'ul_value' => $timestamp ],
119 if ( !
$cache->add( $this->key, 1, 60 * 60 ) ) {
124 if ( !$dbw->lock( $this->key, __METHOD__, 0 ) ) {
145 'database' => $this->config->get(
'DBtype' ),
146 'MediaWiki' => $this->config->get(
'Version' ),
147 'PHP' => PHP_VERSION,
148 'OS' => PHP_OS .
' ' . php_uname(
'r' ),
149 'arch' => PHP_INT_SIZE === 8 ? 64 : 32,
150 'machine' => php_uname(
'm' ),
153 if ( isset( $_SERVER[
'SERVER_SOFTWARE'] ) ) {
154 $event[
'serverSoftware'] = $_SERVER[
'SERVER_SOFTWARE'];
157 $limit = ini_get(
'memory_limit' );
158 if ( $limit && $limit != -1 ) {
159 $event[
'memoryLimit'] = $limit;
172 'schema' =>
'MediaWikiPingback',
173 'revision' => self::SCHEMA_REV,
190 'updatelog',
'ul_value', [
'ul_key' =>
'PingBack' ] );
192 if (
$id ==
false ) {
197 [
'ul_key' =>
'PingBack',
'ul_value' =>
$id ],
202 if ( !$dbw->affectedRows() ) {
203 $id = $dbw->selectField(
204 'updatelog',
'ul_value', [
'ul_key' =>
'PingBack' ] );
231 $queryString = rawurlencode( str_replace(
' ',
'\u0020', $json ) ) .
';';
232 $url =
'https://www.mediawiki.org/beacon/event?' . $queryString;
233 return MediaWikiServices::getInstance()->getHttpRequestFactory()->post( $url ) !==
null;
253 $this->logger->debug( __METHOD__ .
": couldn't acquire lock" );
259 $this->logger->warning( __METHOD__ .
": failed to send pingback; check 'http' log" );
264 $this->logger->debug( __METHOD__ .
": pingback sent OK ({$this->key})" );
275 if ( $instance->shouldSend() ) {
static getLocalClusterInstance()
Get the main cluster-local cache object.
getSystemInfo()
Collect basic data about this MediaWiki installation and return it as an associative array conforming...
checkIfSent()
Has a pingback been sent in the last month for this MediaWiki version?
Interface for configuration instances.
sendPingback()
Send information about this MediaWiki instance to MediaWiki.org.
Send information about this MediaWiki instance to MediaWiki.org.
string $id
Randomly-generated identifier for this wiki.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
acquireLock()
Acquire lock for sending a pingback.
markSent()
Record the fact that we have sent a pingback for this MediaWiki version, to ensure we don't submit da...
shouldSend()
Should a pingback be sent?
getData()
Get the EventLogging packet to be sent to the server.
__construct(Config $config=null, LoggerInterface $logger=null)
static generateHex( $chars)
Generate a run of cryptographically random data and return it in hexadecimal string format.
static getMain()
Get the RequestContext object associated with the main request.
string $key
updatelog key (also used as cache/db lock key)
postPingback(array $data)
Serialize pingback data and send it to MediaWiki.org via a POST to its event beacon endpoint.
static schedulePingback()
Schedule a deferred callable that will check if a pingback should be sent and (if so) proceed to send...
getOrCreatePingbackId()
Get a unique, stable identifier for this wiki.
static addCallableUpdate( $callable, $stage=self::POSTSEND, $dbw=null)
Add a callable update.