ZF-4269: Zend_Captcha_Image should check if a file with the unique name already exists

Description

Zend_Captcha_Image should check if a file with the generated unique name already exists. On systems where there is a high load it could happen that a unique id gets generated twice. I know this is very unlikely but it could happen.

After generation of the id there should be an check if a file with that name already exists and if yes a new id should be generated. I have created a fix that i will append to this issue. If the unique id generation fails three times an exception will be thrown.

Comments

Added logic to the generate method to check if a filename with the generated it exists, if yes a new id will be generated. If the generation fails three times an exception will be thrown.

Ugh, i just saw that there is a suffix property that should be used instead of hardcoding the suffix into the path like in my patch file. Because there is no way to delete or reupload previously uploaded fixes i wont reprovide the changed verison to avoid confusion.

Did you actually see it happen? This requires that PHP random generator would give the same number in same microsecond for two processes. Is it a real problem?

I did not saw it happen but it could happen. And prevention is better then a late reaction.

fixed, thanks