Re: Error Reporting for file commands

From: Date: Fri, 04 Aug 2006 21:19:46 +0000
Subject: Re: Error Reporting for file commands
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-240164@lists.php.net to get a copy of this message
On Tue, July 25, 2006 10:32 am, James Nunnerley wrote: > We've created a file manager which allows users to access their web > space on > a server. It's working brilliantly, except that it would seem there > are > some caching issues, either by the system cache or the web server > cache that > are causing us a headache. > > When the script tries to delete a file, we always check (using > file_exists) > to see whether the file exists before it's deleted. But if some other process is deleting that file, you have a race condition. It's pointless to check before you delete, really -- You simply have to use the result from unlink() to know if it worked or not. > The check comes back true, but the unlink then fails, saying no file > or > directory there! > > We've tried turning off all errors (using error_reoprting(0) ) but > this > would seem to have little difference in the error - it still comes > back with > a failure. Any time the solution is error_reporting(0) then you are doing something fundamentally wrong. > We are using our own error handling, but before the command is carried > out, > there is this 0 call... If you use set_error_handler(), it is called regardless of error_reporting() settings. http://php.net/set_error_handler > Does anyone know how we can stop these errors? I would suggest that you make sure that you are using the FULL PATH to unlink() -- Relying on any kind of relative path is just going to get you into trouble. -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#240164) next »