What makes PHP block files

On my server, sometimes scripts and cache files created by scripts are blocked by the PHP process. After blocking, they cannot be accessed either through a network resource, locally on the server, or by PHP itself. Refreshing the page results in access denials:

Warning: rmdir(C:\inetpub\wwwroot\mdblog\public\..\cache\posts\2012) [function.rmdir]: Directory not empty in C:\inetpub\wwwroot\mdblog\public\system\Filesystem.php on line 52 

Line 52 is rmdir($dir); .

The problem is more common after a "large" number of disk operations (quickly refreshing the page, deleting several files at once, etc.). This is a Windows Server 2008 R2 server with IIS7 and PHP 5.3.13 (using FastCGI), running on a VM server, without virus scanners, with PHP installed using the Web Platform installer. dxdiag

Running iisreset temporarily fixes the problem. However, I am writing a static site generation function that causes this problem to occur every few minutes.

+4
source share
2 answers

Is it possible that your script chdir () is ed into a directory? On Windows, you cannot delete the current directory of any running process. Sometimes you may receive strange messages (for example, β€œthe directory is not empty”), while the real reason is that processes working with this directory work in it.

My idea is that IIS supports PHP processes (because starting new processes on Windows is a difficult operation), and therefore unused processes in the pool prevent you from deleting these directories. By restarting IIS, you delete all processes in the pool, which makes deletion possible.

Try chdir () in the default directory at the end of your PHP scripts and see if it works.

0
source

As the error says, the folder is not empty, so it cannot be deleted. Maybe because not all temporary files are deleted. Try to implement and use a recursive function ...

 function rrmdir($dir) { foreach(glob($dir . '/*') as $file) { if(is_dir($file)) rrmdir($file); else unlink($file); } rmdir($dir); } 

This function will delete everything inside the folder and then delete it.

-2
source

Source: https://habr.com/ru/post/1437385/


All Articles