"Correcting String::uuid(); output when $pid > 65535"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6202 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-12-22 20:05:34 +00:00
parent ba5713391d
commit 41d0e78681

View file

@ -136,13 +136,13 @@ class String extends Object {
$pid = getmypid();
}
if (!$pid) {
if (!$pid || $pid > 65535) {
$pid = mt_rand(0, 0xfff) | 0x4000;
}
list($timeMid, $timeLow) = explode(' ', microtime());
$uuid = sprintf("%08x-%04x-%04x-%02x%02x-%04x%08x", (int)$timeLow, (int)substr($timeMid, 2) & 0xffff,
mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3f) | 0x80, mt_rand(0, 0xff), substr($pid, 0, 5), $node);
mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3f) | 0x80, mt_rand(0, 0xff), $pid, $node);
return $uuid;
}