[wp-trac] [WordPress Trac] #55194: wp_rand( 0, 0) result in random integer

WordPress Trac noreply at wordpress.org
Fri Feb 18 17:15:34 UTC 2022


#55194: wp_rand( 0, 0)  result in random integer
--------------------------+---------------------
 Reporter:  mlajo         |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  6.0
Component:  General       |     Version:  5.9
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  docs
--------------------------+---------------------
Changes (by SergeyBiryukov):

 * keywords:   => has-patch


Comment:

 Replying to [comment:8 mlajo]:
 > This is not consistent with mt_rand and contra intuitive.

 What I meant by consistency is that both `mt_rand()` and `wp_rand()`, when
 called without any parameters, return a random number. But you're right
 that the results for `mt_rand( 0, 0 )` and `wp_rand( 0, 0 )` are
 inconsistent.

 On second thought, maybe we could still fix it, see
 [attachment:55194.diff]. This would need a unit test and security review.

 > It caused lots of trouble in our code until we pinpoint it to this
 function.

 Just out of curiousity, what would be the use case for a `wp_rand( 0, 0 )`
 call?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55194#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list