Fixed Discouragement "Loading delay" allows incorrect order of values

mattrogowski

Well-known member
Licensed customer
Affected version
2.3.7
You can enter values of "30" and "20" like this:

1765462561530.webp

This then throws an error ValueError: mt_rand(): Argument #2 ($max) must be greater than or equal to argument #1 ($min) src/XF/Pub/Controller/AbstractController.php:529

Should either validate the option values to enforce they're the right way round, or check which one is larger in the controller. I guess instead of:

PHP:
mt_rand($options->discourageDelay['min'], $options->discourageDelay['max'])

could do:

PHP:
mt_rand(min($options->discourageDelay['min'], $options->discourageDelay['max']), max($options->discourageDelay['min'], $options->discourageDelay['max']))
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.10).

Change log:
Normalize discouragement delay min/max values to prevent mt_rand() ValueError
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom