Re: BC break with rand() where min > max
| From: | Leigh | Date: | Wed, 10 Aug 2016 22:44:45 +0000 |
| Subject: | Re: BC break with rand() where min > max | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-95030@lists.php.net to get a copy of this message | ||
On Wed, 10 Aug 2016 at 14:19 Tom Worster <fsb@thefsb.org> wrote:
> Your fix seems fine for rand() but less so for mt_rand().
>
> Applying this fix will break much less mt_rand()-using code than not
> applying it will break rand()-using code. From that point of view,
> applying it is the better choice.
>
> Otoh, it's like copy-pasting a weird old bug from rand() to mt_rand().
> The plan was to make rand() alias mt_rand(). Now I'm not sure that's a
> smart plan.
>
> Tom
>
I've pushed a fix that keeps the old behaviour for both
I've un-aliased rand from mt_rand, added a min > max check to rand, and
then call the common code with parameters reversed if necessary.