From: Tjerk Meesters [mailto:tjerk.meesters@gmail.com]
Sent: Tuesday, November 26, 2013 1:42 AM
> On Tue, Nov 26, 2013 at 5:19 PM, Ferenc Kovacs <tyra3l@gmail.com<mailto:tyra3l@gmail.com>> wrote:
> 2013.11.26. 7:31, "Nikita Popov" <nikita.ppv@gmail.com<mailto:nikita.ppv@gmail.com>> ezt írta:
> >
> > On Mon, Nov 25, 2013 at 8:30 PM, Eric Stenson <ericsten@microsoft.com<mailto:ericsten@microsoft.com>
> >wrote:
[...]
> > > $ui1 = uniqid($str);
> > > +/* Must sleep here to let uniqid generate a different unique ID */
> > > +usleep( 10 );
> > > $ui2 = uniqid($str);
> > >
> > > $len = strncasecmp(PHP_OS, 'CYGWIN', 6) ? 19 : 29;
> > >
>
> Internally, uniqid() uses usleep(1) only if 'more entropy' is omitted and not on
> Windows and Cygwin (must use 'more entropy').
>
> So, when 'more entropy' is present, it will skip usleep(1) but pad the result with
> php_combined_lcg().
>
> I'm sure there was a good reason to do so, but it does seem counter-intuitive at best.
>
Ah! My bad. Please remove the usleep(10) and add the ', true' (more entropy) param to
the uniqid() call. This test consistently fails on Windows.
For completeness of coverage, you might consider also testing with the usleep(1) and without the
', true' (more entropy) param.
Thx!
--E.