Issue Bug Closed

#59701uniqid() not returning unique values

Tymoteusz Motylewski 06/20/14, 12:41 updated 10/02/18, 11:54

Description

uniqid() generates values based on current time,
subsequent calls may return the same value on a fast machine.

On Windows it’s even worse, as uniqid()
has single-second-resolution out of the box.

Right now it is used in many places in the core, also for creating temporary identifiers for newly created records (in the datahanlder)

The solution is to add a second parameter to all calls (which adds more entropy).
see http://php.net/manual/en/function.uniqid.php

uniqid(“prefix”) => uniqid(“prefix”, TRUE)

With an empty prefix, the returned string will be 13 characters long. If more_entropy is TRUE, it will be 23 characters. So we need to test whether having longer id doesn;t break anything.

Reviews 2