Edit report at https://bugs.php.net/bug.php?id=27182&edit=1
ID: 27182 Updated by: yohg...@php.net Reported by: sagawa at sohgoh dot net Summary: [Patch] uniqid("prefix", 0) now works under recent cygwin -Status: Open +Status: Feedback Type: Feature/Change Request -Package: Feature/Change Request +Package: *General Issues Operating System: CYGWIN_NT-5.1 1.5.7 PHP Version: 4.3.5RC2 Block user comment: N Private report: N New Comment: Please try using this snapshot: http://snaps.php.net/php5.4-latest.tar.gz For Windows: http://windows.php.net/snapshots/ Previous Comments: ------------------------------------------------------------------------ [2004-02-08 00:40:54] sagawa at sohgoh dot net 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 this bug report at https://bugs.php.net/bug.php?id=27182&edit=1