Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

uniqid() is not unique enough so add usleep to ensure uniqueness #157

Merged
merged 3 commits into from
Feb 18, 2015
Merged

uniqid() is not unique enough so add usleep to ensure uniqueness #157

merged 3 commits into from
Feb 18, 2015

Conversation

chbiel
Copy link
Contributor

@chbiel chbiel commented Feb 18, 2015

When uniqid is executed to fast in a row the generated id's are unique. usleep ensures a uniqueid

would be 0.12.1 i think

@chbiel
Copy link
Contributor Author

chbiel commented Feb 18, 2015

okay :D there is something new with scrutinizer...

@julianseeger
Copy link
Contributor

Scruzinizer:
Ignore scrutinizer. You could remove the

build_failure_conditions:
  - 'issues.new.exists

from the .scrutinizer.yml to make the build pass after a merge. We can turn it back on after those issues are addressed.

uniqid:
Ok, obvious bug. If the loop is faster than a ms, we get doubled results. But don't you get goosebumps when writing a usleep? ^^
uniqid($i) and uniqid('', true) should both fix the issue without a sleep because the token ($i) is unique within the process and the true should generate enough entropy to be unique within the same ms, shouldn't they?. (preferable prefix with $i because the $more_entropy flag generates uniqids with dots).

build_failure_conditions:
  - 'issues.new.existsremove
  from scrutinizer
@chbiel
Copy link
Contributor Author

chbiel commented Feb 18, 2015

I tried uniqid('', true) but the generated number contains "." what I didnt find that beautiful. uniqid($i) did'nt came to my mind but is used now ;)

@julianseeger
Copy link
Contributor

would be 0.12.1 i think

thanks 👍

julianseeger added a commit that referenced this pull request Feb 18, 2015
uniqid() is not unique enough so add usleep to ensure uniqueness
@julianseeger julianseeger merged commit 26e14a1 into paratestphp:master Feb 18, 2015
@chbiel chbiel deleted the uniqid-fix branch February 18, 2015 12:35
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants