Skip to content

Commit 8e8e204

Browse files
committed
Fix for PHP 8.3 for sampling rate
1 parent 6a199f8 commit 8e8e204

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plugins/wpgraphql-logging/src/Logger/Rules/SamplingRateRule.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ class SamplingRateRule implements LoggingRuleInterface {
2424
*/
2525
public function passes(array $config, ?string $query_string = null): bool {
2626
$sampling_rate = (int) ( $config[ BasicConfigurationTab::DATA_SAMPLING ] ?? 100 );
27-
$rand = wp_rand( 0, 100 );
27+
// If sampling rate is 0, never log.
28+
if ( 1 > $sampling_rate ) {
29+
return false;
30+
}
31+
32+
$rand = wp_rand( 1, 100 );
2833
return $rand <= $sampling_rate;
2934
}
3035

0 commit comments

Comments
 (0)