Steps to replicate the issue (include links if applicable):
- Make sure you're using PHP 8.1+
- Add the following to your LocalSettings.php:
$wgRateLimits['sendemail'] = [ 'user' => [ 1, 1001 ] ];
- Make sure you have caches enabled (e.g., $wgMainCacheType = CACHE_ACCEL)
- Go to Special:EmailUser, choose a valid email target and submit
What happens?:
You'll get the following PHP warnings:
Deprecated: Implicit conversion from float 1034.3666666666666 to int loses precision in /var/www/html/w/includes/libs/WRStats/WRStatsWriter.php on line 70 Deprecated: Implicit conversion from float 1034.3666666666666 to int loses precision in /var/www/html/w/includes/libs/WRStats/WRStatsWriter.php on line 71 Deprecated: Implicit conversion from float 1034.3666666666666 to int loses precision in /var/www/html/w/includes/libs/WRStats/WRStatsWriter.php on line 73
What should have happened instead?:
No PHP warnings.
Software version (skip for WMF-hosted wikis like Wikipedia):
MW master as of 2023-05-31.
Other information (browser name/version, screenshots, etc.):
The issue here is that the ratelimit period (1001) is not a multiple of the bucket count defined in WRStatsRateLimiter (30). The time step is computed as $period / $bucketCount, and in this case it's not an integer. The value is then used as an array key, which emits the deprecation warnings in question. Note that this bug exists with any user right, and potentially things other than the ratelimiter using WRStats.