X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FPingback.php;h=bf2123fae3d3d85bd73355b8002d29fda1d6ca0b;hp=c3393bcc1cecb7b780d0f3d5ac8cd51585c700ae;hb=4bd19c04869f86831a1b9f828d007c90f1083b08;hpb=c355cc53ab6d36498aede46a016521d7bd8ce071 diff --git a/includes/Pingback.php b/includes/Pingback.php index c3393bcc1c..bf2123fae3 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' ], + [ 'ul_value' => $timestamp ], + __METHOD__ + ); } /**