[wp-trac] [WordPress Trac] #59239: wp_generate_uuid4 collisions

WordPress Trac noreply at wordpress.org
Thu Mar 19 00:00:15 UTC 2026


#59239: wp_generate_uuid4 collisions
--------------------------------------------+-----------------------
 Reporter:  joppuyo                         |       Owner:  jorbin
     Type:  defect (bug)                    |      Status:  assigned
 Priority:  normal                          |   Milestone:  7.0
Component:  General                         |     Version:
 Severity:  normal                          |  Resolution:
 Keywords:  has-patch needs-testing commit  |     Focuses:
--------------------------------------------+-----------------------

Comment (by siliconforks):

 Replying to [comment:16 peterwilsoncc]:
 > Running the following using the existing (collision prone) code about
 tenish didn't result in any collisions.

 I don't think you would ever get a collision that way, because the
 [http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html Mersenne
 Twister] has a very long period.  The problem is that the seed is only 32
 bits.

 > As this isn't using `mt_rand` for cryptographic purposes,

 Well, it's a library function, so you don't really know what callers are
 using it for...

 > I think it's fine to use the KISS approach for a `low^2` probability.

 I think KISS is fine too - I would just call `random_int()` and then if it
 throws an exception, let the caller decide what to do with it.

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


More information about the wp-trac mailing list