Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #3819

Re: Prevent unlink(...) warning

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Simon <bad@example.com>
Newsgroups comp.lang.php
Subject Re: Prevent unlink(...) warning
Date Thu, 17 Nov 2011 19:21:52 +0200
Lines 50
Message-ID <9iku5gFi18U1@mid.individual.net> (permalink)
References <9ikm3eFih4U1@mid.individual.net> <ja38jj$au4$1@news.albasani.net>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net nVxNfP1/VMWfnSH4EFT/2gF6tG46OLPe10onmqqqJJAbqbkIXc
Cancel-Lock sha1:qskja/Zj5rchSD9YO22lF7NGVt8=
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0
In-Reply-To <ja38jj$au4$1@news.albasani.net>
Xref x330-a1.tempe.blueboxinc.net comp.lang.php:3819

Show key headers only | View raw


On 2011/11/17 05:18 PM, The Natural Philosopher wrote:
> Simon wrote:
>> Hi,
>>
>> I am having some race condition issues on my server when trying to
>> delete a file.
>>
>
> what makes you think its a race condition?

A guess really,

If I do:
...
if (file_exists($filename))
{

and followed by
...
   @unlink($filename);
}

And that gives me a

unlink(/home/xxx/public_html/temp/yyy.zz) [function.unlink]: No such 
file or directory

The something between file_exists(...) and @unlink(...) must have 
removed the file.
Either that or one of the two functions is not working as expected.

>
> Why do you care about the stat cache?
>

As per the doc, http://php.net/manual/en/function.clearstatcache.php, to 
make sure that file_exists($filename) does return a cached value.

>>
>> How can I prevent the warning?
>>
> Why prevent it at all?
>
> As long as the file is not there when you are finished - why not just
> unlink it anyway?
>

Because the warnings fill my logs and I aim for no warnings at all.

Simon

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Prevent unlink(...) warning Simon <bad@example.com> - 2011-11-17 17:04 +0200
  Re: Prevent unlink(...) warning The Natural Philosopher <tnp@invalid.invalid> - 2011-11-17 15:18 +0000
    Re: Prevent unlink(...) warning Simon <bad@example.com> - 2011-11-17 19:21 +0200
      Re: Prevent unlink(...) warning The Natural Philosopher <tnp@invalid.invalid> - 2011-11-17 18:29 +0000
  Re: Prevent unlink(...) warning "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-11-17 18:42 +0100
  Re: Prevent unlink(...) warning Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-17 13:54 -0500

csiph-web