inEventSample: Avoid invalid character warning from sampling code, hash into hex

Bug: T314896
Change-Id: I377bbe54686fdb9d765543320aef14a99ee2cd7f
This commit is contained in:
James D. Forrester 2022-08-09 17:39:53 -04:00
parent 68b4eae84e
commit 0e3f7c44b2

View file

@ -97,8 +97,12 @@ class Hooks implements
// Sample 6.25%
$samplingRate = $this->config->has( 'WMESchemaEditAttemptStepSamplingRate' ) ?
$this->config->get( 'WMESchemaEditAttemptStepSamplingRate' ) : 0.0625;
// (T314896) Convert whatever we've been given to a string of hex, as that's what EL needs
$hexValue = hash( 'md5', $sessionId, false );
$inSample = EventLogging::sessionInSample(
(int)( 1 / $samplingRate ), $sessionId
(int)( 1 / $samplingRate ), $hexValue
);
return $inSample;
}