-
Notifications
You must be signed in to change notification settings - Fork 27
Use uniqid() to avoid collisions #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use uniqid() to avoid collisions #19
Conversation
Would it be sufficient to use |
Based on some quick Google searches, it looks like
My understanding is that The |
I posed the question on Twitter and it sounds like |
Actually, it looks like |
@colinodell thanks for the thorough research and the adjusted PR. 👍 |
Is there any particular reason why you're adverse to dependencies, especially when they solve the problem more effectively than you need? |
@paragonie-scott I am not adverse to adding a new dependency. I simply wanted to avoid adding one, when there is a simple solution with using the existing dependencies and without adding any additional complexity. I think in this case there is no need for cryptographically secure values, so using |
My understanding is that I'll let you know if I encounter any future issues - if so, |
We use this plugin in projects which are tested via Gitlab CI. Some of these projects test multiple versions of PHP simultaneously. To achieve better performance and keep bandwidth usage low, our runners use a shared Composer cache.
It's extremely likely we'll have two
composer install
commands start (and be running) at the same second with the samecomposer.json
contents. As a result, the "unique" path used by the plugin ends up being the same in both runners. This leads to situations where one job is adding/deleting files and folders currently being used by the other one, causing it to fail.I therefore propose using a different method to generate a unique path which is not based on the time in seconds.
random_bytes()
uniqid('', true)
seems to fit this need nicely.