|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-09-05 22:46 UTC] cmbecker69 at gmx dot de
Description: ------------ From looking at the sources[1], it occurs to me that uniqid(null, false) doesn't *guarantee* to return a unique identifier on WIN32, because usleep(3) is skipped. As usleep() is implemented as PHP userland function since PHP 5.0.0[2], it seems to be reasonable and possible to add the equivalent to usleep(3) there. As far as I can tell, this won't introduce any BC issues, so the change might be done for PHP 5.4.x. Please note that this is related to #37106[3], but helly's comment doesn't seem to fit to the current sources. [1] <http://lxr.php.net/xref/PHP_5_4/ext/standard/uniqid.c#61> [2] <http://lxr.php.net/xref/PHP_5_4/win32/time.c#96> [3] <https://bugs.php.net/bug.php?id=37106> Test script: --------------- var_dump(uniqid(null, false) != uniqid(null, false)); Expected result: ---------------- bool(true) Actual result: -------------- bool(false) // at least sometimes on a fast machine ;) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 23:00:02 2025 UTC |
It seems uniqid() has protection under UNIXes. #if HAVE_USLEEP && !defined(PHP_WIN32) if (!more_entropy) { #if defined(__CYGWIN__) php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must use 'more entropy' under CYGWIN"); RETURN_FALSE; #else usleep(1); #endif } #endif Why is this disabled for windows?