Jeff-Lewis / smarty-php

Automatically exported from code.google.com/p/smarty-php
0 stars 0 forks source link

RecursiveDirectoryIterator::__construct(D:/WWW/cache\cache_f\cache_ff) [recursivedirectoryiterator.--construct]: failed to open dir: Directory not empty #143

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Stack trace:
#0 [internal function]: 
RecursiveDirectoryIterator->__construct('D:/WWW/cach...')
#1 
D:\WWW\nod\lib\Smarty\sysplugins\smarty_internal_cacheresource_file.php(180): 
RecursiveDirectoryIterator->getChildren()
#2 D:\WWW\nod\lib\Smarty\Smarty.class.php(772): 
Smarty_Internal_CacheResource_File->clear(Object(...), 'orders/coordina...', 
'orders', NULL, NULL)

Error happens when smarty is clearing cache and as i understand it cannot open 
some folder. the getChildren documentation is incomplete. it's being called 
then foreach is executed on variable $_cache on line 180 in 
sysplugins\smarty_internal_cacheresource_file.php

And new RecursiveDirectoryIterator($_dir) should include flag 
FilesystemIterator::SKIP_DOTS

as @rmdir suppresses warnings i take it unable to delete folders is not really 
important, so maybe try catch block should be added to handle unreadable 
folders locked by some processes or any other reasons.

Original issue reported on code.google.com by Justin...@gmail.com on 11 Jul 2013 at 9:14

GoogleCodeExporter commented 9 years ago
Smarty v3.1.13
PHP v5.2.17
Platform Windows Server 2008 R2 x64
PHP runs as FastCGI on IIS

Original comment by Justin...@gmail.com on 11 Jul 2013 at 9:15

GoogleCodeExporter commented 9 years ago
Do you have any idea why this happened and a folder was not readable?
In my opinion this case should throw an excpetion as there is a chance that 
clear(..) will not be executed correctly.

FilesystemIterator::SKIP_DOTS should not be used because empty subfolders shall 
be deleted.

Original comment by Uwe.Tews@googlemail.com on 12 Jul 2013 at 12:40

GoogleCodeExporter commented 9 years ago
this happens sometimes, so hard to reproduce. It could be because the folder is 
locked by another process, maybe writing to that folder at the same time, as 
clear happens, some cache race condition maybe.

>In my opinion this case should throw an excpetion as there is a chance that 
clear(..) will not be executed correctly.

But from the code i see rmdir errors are suppressed and there is no check there 
to verify that the folder was deleted, the same is with unlink in the else 
clause. What i'm saying is you don't produce an error if you can't delete a 
folder or a file, that would indicate that clear did not execute correctly, you 
just skip it,why not just skip unreadable folders also, i mean apply the same 
logic (rewrite foreach() into a while() with try{} catch() inside to suppress 
errors for unreadable folders).

just a thought, but why do you need to remove folders, if on cache populate 
smarty is just going to recreate them. Just leaving empty folders would save 
some I/O and maybe CPU time.

Original comment by Justin...@gmail.com on 12 Jul 2013 at 5:51

GoogleCodeExporter commented 9 years ago
Smarty does create a subfolder structure based on cache_id. The rmdir should 
remove empty folders because they may not be reused in future because old 
cache_id's may not reoccur. It's error supressed beauce the current clear() may 
not remove all entries.

I did not expect exceptions when I wrote the code. But with your input I will 
look for a solution to catch these.

Original comment by Uwe.Tews@googlemail.com on 13 Jul 2013 at 10:23

GoogleCodeExporter commented 9 years ago
Maybe this was related the the problem reported and fix in issue 171.

I close this now.
Please reopen if the problem still occurs.

Original comment by Uwe.Tews@googlemail.com on 27 Jan 2014 at 4:46

GoogleCodeExporter commented 9 years ago
there is no open_basedir restriction in my case and i use smarty 3.x not v2

Original comment by Justin...@gmail.com on 27 Jan 2014 at 6:31

GoogleCodeExporter commented 9 years ago

Original comment by Uwe.Tews@googlemail.com on 28 Jan 2014 at 1:49