From: sagawa at sohgoh dot net Operating system: CYGWIN_NT-5.1 1.5.7 PHP version: 4.3.5RC2 PHP Bug Type: Strings related Bug description: [Patch] uniqid("prefix", 0) now works under recent cygwin
Description: ------------ According to cygwin-patches(*1) and ChangeLog(*2), Cygwin's usleep now advances system clock(gettimeofday). *1 .. http://sources.redhat.com/ml/cygwin-patches/2003-q3/msg00178.html *2 .. http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/signal.cc?cvsroot=src#rev1.48 Therefore I can use uniqid safely when more entropy flag is zero, I made a patch. (but "more entropy flag" is still on by default for backward compatibility) Unfortunary cygwin doesn't change version for this change, I apply most recent change of CYGWIN_VERSION_API_MINOR. "String functions [tests/strings/001.phpt]" now pass! --- php-4.3.5RC2/ext/standard/uniqid.c.orig 2003-01-01 01:35:35.000000000 +0900 +++ php-4.3.5RC2/ext/standard/uniqid.c 2004-02-08 13:01:49.006220800 +0900 @@ -34,6 +34,9 @@ #else #include <sys/time.h> #endif +#if defined(__CYGWIN__) +#include <cygwin/version.h> +#endif #include "php_lcg.h" #include "uniqid.h" @@ -66,7 +69,7 @@ } #if HAVE_USLEEP && !defined(PHP_WIN32) if (!more_entropy) { -#if defined(__CYGWIN__) +#if defined(__CYGWIN__) && (CYGWIN_VERSION_API_MINOR < 91) php_error_docref(NULL TSRMLS_CC, E_ERROR, "You must use 'more entropy' under CYGWIN."); return; #else --- php-4.3.5RC2/tests/strings/001.phpt.orig 2001-03-21 21:47:46.000000000 +0900 +++ php-4.3.5RC2/tests/strings/001.phpt 2004-02-08 13:23:53.320491200 +0900 @@ -181,8 +181,8 @@ echo "Testing uniqid: "; $str = "prefix"; -$ui1 = uniqid($str); -$ui2 = uniqid($str); +$ui1 = uniqid($str, 0); +$ui2 = uniqid($str, 0); if (strlen($ui1) == strlen($ui2) && strlen($ui1) == 19 && $ui1 != $ui2) { echo("passed\n"); } else { Reproduce code: --------------- <?php echo uniqid("prefix"),"\n"; echo uniqid("prefix", 1),"\n"; echo uniqid("prefix", 0),"\n"; echo uniqid("prefix", 0),"\n"; echo uniqid("prefix", 0),"\n"; ?> Expected result: ---------------- -- cygwin -- prefix4025c46680d100.85790027 prefix4025c466810f81.04902838 prefix4025c466814e0 prefix4025c466818c8 prefix4025c46681cb0 -- linux -- prefix4025c4a472847 prefix4025c4a47289a3.07476264 prefix4025c4a47766a prefix4025c4a47c487 prefix4025c4a4812a8 Actual result: -------------- -- cygwin(NG) -- PHP Fatal error: uniqid(): You must use 'more entropy' under CYGWIN. in /home/sagawa/uniqid_test.php on line 4 prefix4025c46680d100.85790027 prefix4025c466810f81.04902838 -- linux(OK) -- prefix4025c4a472847 prefix4025c4a47289a3.07476264 prefix4025c4a47766a prefix4025c4a47c487 prefix4025c4a4812a8 -- Edit bug report at http://bugs.php.net/?id=27182&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27182&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27182&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27182&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27182&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27182&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27182&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27182&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27182&r=support Expected behavior: http://bugs.php.net/fix.php?id=27182&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27182&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27182&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27182&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27182&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27182&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27182&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27182&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27182&r=float