Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.10.5
-
Fix Version/s: 1.10.7
-
Component/s: Zend_Captcha
-
Labels:None
Description
The garbage collector for Zend_Captcha_Image (Zend_Captcha_Image::_gc()) deletes all the files inside the directory used to store the captcha's images (including hidden files). This is a problem if you want to use a directory that is used by other parts of your application.
Bellow a patch that fix the issue. With this change the garbage collector will only delete files that match the suffix.
--- Image.php 2010-06-17 13:25:20.000000000 -0400
+++ Image.php 2010-06-17 13:25:16.000000000 -0400
@@ -580,7 +580,11 @@
foreach (new DirectoryIterator($imgdir) as $file) {
if (!$file->isDot() && !$file->isDir()) {
if ($file->getMTime() < $expire) {
- unlink($file->getPathname());
+ $len = strlen($this->_suffix);
+ // only deletes files ending with $this->_suffix
+ if (substr($file->getFilename(), -($len), $len) == $this->_suffix) {
+ unlink($file->getPathname());
+ }
}
}
}
The same patcha provide in the bug description