X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FPingback.php;h=64b54f1e4b1d99aa0c5f8343349eb61d1c96b923;hb=f6a35d8674257bed158cabe5e541fc62973f1f8f;hp=bd1b2a25b43912f321f65fc4fa08ba40c5d60ae8;hpb=7874fc4bec845ad92960b07e969c65f3c3fe74f2;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Pingback.php b/includes/Pingback.php index bd1b2a25b4..64b54f1e4b 100644 --- a/includes/Pingback.php +++ b/includes/Pingback.php @@ -68,14 +68,25 @@ class Pingback { } /** - * Has a pingback already been sent for this MediaWiki version? + * Has a pingback been sent in the last month for this MediaWiki version? * @return bool */ private function checkIfSent() { $dbr = wfGetDB( DB_REPLICA ); - $sent = $dbr->selectField( - 'updatelog', '1', [ 'ul_key' => $this->key ], __METHOD__ ); - return $sent !== false; + $timestamp = $dbr->selectField( + 'updatelog', + 'ul_value', + [ 'ul_key' => $this->key ], + __METHOD__ + ); + if ( $timestamp === false ) { + return false; + } + // send heartbeat ping if last ping was over a month ago + if ( time() - (int)$timestamp > 60 * 60 * 24 * 30 ) { + return false; + } + return true; } /** @@ -84,8 +95,14 @@ class Pingback { */ private function markSent() { $dbw = wfGetDB( DB_MASTER ); - return $dbw->insert( - 'updatelog', [ 'ul_key' => $this->key ], __METHOD__, 'IGNORE' ); + $timestamp = time(); + return $dbw->upsert( + 'updatelog', + [ 'ul_key' => $this->key, 'ul_value' => $timestamp ], + [ 'ul_key' => $this->key ], + [ 'ul_value' => $timestamp ], + __METHOD__ + ); } /** @@ -228,6 +245,7 @@ class Pingback { * * The schema for the data is located at: * + * @return bool */ public function sendPingback() { if ( !$this->acquireLock() ) {