ZF-10006: Zend_Captcha_Image::_gc() does not consider file suffix
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());
+ }
}
}
}
Comments
Posted by Rodrigo Primo (rodrigosprimo) on 2010-06-17T10:37:19.000+0000
The same patcha provide in the bug description
Posted by Mickael Perraud (mikaelkael) on 2010-07-16T13:54:22.000+0000
Fixed in trunk with r22589 and applied on 1.10 branch with r22590
Posted by Rodrigo Primo (rodrigosprimo) on 2010-07-16T17:56:55.000+0000
Thanks :-)