38 const SCHEMA_REV = 15781718;
57 $this->config =
$config ?: RequestContext::getMain()->getConfig();
58 $this->logger =
$logger ?: LoggerFactory::getInstance( __CLASS__ );
59 $this->
key =
'Pingback-' . $this->config->get(
'Version' );
67 return $this->config->get(
'Pingback' ) && !$this->
checkIfSent();
76 $timestamp =
$dbr->selectField(
79 [
'ul_key' => $this->
key ],
82 if ( $timestamp ===
false ) {
86 if ( time() - (
int)$timestamp > 60 * 60 * 24 * 30 ) {
101 [
'ul_key' => $this->
key,
'ul_value' => $timestamp ],
103 [
'ul_value' => $timestamp ],
117 $cache = ObjectCache::getLocalClusterInstance();
118 if ( !
$cache->add( $this->key, 1, 60 * 60 ) ) {
123 if ( !$dbw->lock( $this->key, __METHOD__, 0 ) ) {
144 'database' => $this->config->get(
'DBtype' ),
145 'MediaWiki' => $this->config->get(
'Version' ),
148 'arch' => PHP_INT_SIZE === 8 ? 64 : 32,
152 if (
isset( $_SERVER[
'SERVER_SOFTWARE'] ) ) {
153 $event[
'serverSoftware'] = $_SERVER[
'SERVER_SOFTWARE'];
156 $limit =
ini_get(
'memory_limit' );
157 if ( $limit && $limit != -1 ) {
158 $event[
'memoryLimit'] = $limit;
171 'schema' =>
'MediaWikiPingback',
189 'updatelog',
'ul_value', [
'ul_key' =>
'PingBack' ] );
191 if (
$id ==
false ) {
196 [
'ul_key' =>
'PingBack',
'ul_value' =>
$id ],
201 if ( !$dbw->affectedRows() ) {
202 $id = $dbw->selectField(
203 'updatelog',
'ul_value', [
'ul_key' =>
'PingBack' ] );
229 $json = FormatJson::encode(
$data );
231 $url =
'https://www.mediawiki.org/beacon/event?' .
$queryString;
252 $this->logger->debug( __METHOD__ .
": couldn't acquire lock" );
258 $this->logger->warning( __METHOD__ .
": failed to send pingback; check 'http' log" );
263 $this->logger->debug( __METHOD__ .
": pingback sent OK ({$this->key})" );
272 DeferredUpdates::addCallableUpdate(
function () {
274 if ( $instance->shouldSend() ) {
275 $instance->sendPingback();
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static post( $url, array $options=[], $caller=__METHOD__)
Simple wrapper for Http::request( 'POST' )
static generateHex( $chars)
Generate a run of 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 been sent in the last month for this MediaWiki version?
getSystemInfo()
Collect basic data about this MediaWiki installation and return it as an associative array conforming...
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message key
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
Interface for configuration instances.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))