23use Psr\Log\LoggerInterface;
38 const SCHEMA_REV = 15781718;
58 $this->logger =
$logger ?: LoggerFactory::getInstance( __CLASS__ );
59 $this->
key =
'Pingback-' . $this->config->get(
'Version' );
67 return $this->config->get(
'Pingback' ) && !$this->
checkIfSent();
76 $sent =
$dbr->selectField(
77 'updatelog',
'1', [
'ul_key' => $this->
key ], __METHOD__ );
78 return $sent !==
false;
88 'updatelog', [
'ul_key' => $this->
key ], __METHOD__,
'IGNORE' );
100 $cache = ObjectCache::getLocalClusterInstance();
101 if ( !
$cache->add( $this->key, 1, 60 * 60 ) ) {
106 if ( !$dbw->lock( $this->key, __METHOD__, 0 ) ) {
127 'database' => $this->config->get(
'DBtype' ),
128 'MediaWiki' => $this->config->get(
'Version' ),
129 'PHP' => PHP_VERSION,
130 'OS' => PHP_OS .
' ' . php_uname(
'r' ),
131 'arch' => PHP_INT_SIZE === 8 ? 64 : 32,
132 'machine' => php_uname(
'm' ),
135 if ( isset( $_SERVER[
'SERVER_SOFTWARE'] ) ) {
136 $event[
'serverSoftware'] = $_SERVER[
'SERVER_SOFTWARE'];
139 $limit = ini_get(
'memory_limit' );
140 if ( $limit && $limit != -1 ) {
141 $event[
'memoryLimit'] = $limit;
154 'schema' =>
'MediaWikiPingback',
155 'revision' => self::SCHEMA_REV,
172 'updatelog',
'ul_value', [
'ul_key' =>
'PingBack' ] );
174 if (
$id ==
false ) {
179 [
'ul_key' =>
'PingBack',
'ul_value' =>
$id ],
184 if ( !$dbw->affectedRows() ) {
185 $id = $dbw->selectField(
186 'updatelog',
'ul_value', [
'ul_key' =>
'PingBack' ] );
212 $json = FormatJson::encode( $data );
213 $queryString = rawurlencode( str_replace(
' ',
'\u0020', $json ) ) .
';';
214 $url =
'https://www.mediawiki.org/beacon/event?' . $queryString;
215 return Http::post( $url ) !==
false;
235 $this->logger->debug( __METHOD__ .
": couldn't acquire lock" );
241 $this->logger->warning( __METHOD__ .
": failed to send pingback; check 'http' log" );
246 $this->logger->debug( __METHOD__ .
": pingback sent OK ({$this->key})" );
255 DeferredUpdates::addCallableUpdate(
function () {
257 if ( $instance->shouldSend() ) {
258 $instance->sendPingback();
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static generateHex( $chars, $forceStrong=false)
Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format.
Send information about this MediaWiki instance to MediaWiki.org.
acquireLock()
Acquire lock for sending a pingback.
getOrCreatePingbackId()
Get a unique, stable identifier for this wiki.
sendPingback()
Send information about this MediaWiki instance to MediaWiki.org.
shouldSend()
Should a pingback be sent?
getData()
Get the EventLogging packet to be sent to the server.
postPingback(array $data)
Serialize pingback data and send it to MediaWiki.org via a POST to its event beacon endpoint.
string $id
Randomly-generated identifier for this wiki.
string $key
updatelog key (also used as cache/db lock key)
markSent()
Record the fact that we have sent a pingback for this MediaWiki version, to ensure we don't submit da...
__construct(Config $config=null, LoggerInterface $logger=null)
static schedulePingback()
Schedule a deferred callable that will check if a pingback should be sent and (if so) proceed to send...
checkIfSent()
Has a pingback already been sent for this MediaWiki version?
getSystemInfo()
Collect basic data about this MediaWiki installation and return it as an associative array conforming...
static getMain()
Static methods.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
the array() calling protocol came about after MediaWiki 1.4rc1.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php