X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Frdbms%2FChronologyProtector.php;h=b0dc10ebed9e1d24faedd08b59fa4c2480d1e9a3;hb=2f1e5a8d22d7c005e72f8bdb732e6d7076ac3344;hp=099f172e7f971d860916981fb1a6b01e561e0557;hpb=59cc46fa644563786e86440fefbbbd599f39d951;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/rdbms/ChronologyProtector.php b/includes/libs/rdbms/ChronologyProtector.php index 099f172e7f..b0dc10ebed 100644 --- a/includes/libs/rdbms/ChronologyProtector.php +++ b/includes/libs/rdbms/ChronologyProtector.php @@ -43,6 +43,8 @@ class ChronologyProtector implements LoggerAwareInterface { protected $key; /** @var string Hash of client parameters */ protected $clientId; + /** @var string[] Map of client information fields for logging */ + protected $clientLogInfo; /** @var int|null Expected minimum index of the last write to the position store */ protected $waitForPosIndex; /** @var int Max seconds to wait on positions to appear */ @@ -70,15 +72,24 @@ class ChronologyProtector implements LoggerAwareInterface { /** * @param BagOStuff $store - * @param array[] $client Map of (ip: , agent: ) + * @param array[] $client Map of (ip: , agent: [, clientId: ] ) * @param int|null $posIndex Write counter index [optional] * @since 1.27 */ public function __construct( BagOStuff $store, array $client, $posIndex = null ) { $this->store = $store; - $this->clientId = md5( $client['ip'] . "\n" . $client['agent'] ); + $this->clientId = isset( $client['clientId'] ) + ? $client['clientId'] + : md5( $client['ip'] . "\n" . $client['agent'] ); $this->key = $store->makeGlobalKey( __CLASS__, $this->clientId, 'v2' ); $this->waitForPosIndex = $posIndex; + + $this->clientLogInfo = [ + 'clientIP' => $client['ip'], + 'clientAgent' => $client['agent'], + 'clientId' => $client['clientId'] ?? null + ]; + $this->logger = new NullLogger(); } @@ -86,6 +97,14 @@ class ChronologyProtector implements LoggerAwareInterface { $this->logger = $logger; } + /** + * @return string Client ID hash + * @since 1.32 + */ + public function getClientId() { + return $this->clientId; + } + /** * @param bool $enabled Whether to no-op all method calls * @since 1.27 @@ -298,7 +317,7 @@ class ChronologyProtector implements LoggerAwareInterface { [ 'cpPosIndex' => $this->waitForPosIndex, 'waitTimeMs' => $waitedMs - ] + ] + $this->clientLogInfo ); } else { $this->logger->warning( @@ -307,7 +326,7 @@ class ChronologyProtector implements LoggerAwareInterface { 'cpPosIndex' => $this->waitForPosIndex, 'indexReached' => $indexReached, 'waitTimeMs' => $waitedMs - ] + ] + $this->clientLogInfo ); } } else {