0

I got a weird issue I'm not able to fix.

I got the following code which gets called several times from different requests

if(file_exists("settings.ini"))
{
    $ini = parse_ini_file("settings.ini", true);

    // do things with $ini
}

as you can see I'm just parsing the ini file and this is the only place in my whole code where I'm touching this file. However sometimes the file_exists-call returns false (never the first time) even if I call clearstatcache before. The file permission is set to 0755.

Can anyone explain me why this is happening and how to avoid that?

Update

I've noticed that this is only happening if I'm using Firefox (V50). Chrome and IE working fine.

Nitro.de
  • 821
  • 10
  • 27
  • You're calling it from different folders? – Mark Baker Nov 28 '16 at 11:49
  • Assuming you're using Linux, you could try to use [strace](http://stackoverflow.com/questions/174942/how-should-strace-be-used) to see what files are being opened and when. – José Luis Nov 28 '16 at 11:49
  • @MarkBaker nope always same folder. The *.php and *.ini in the same folder. Absolute/relative makes no difference here, already tried – Nitro.de Nov 28 '16 at 11:49
  • Append an `else fopen("settings.ini", "r");` Perhaps the error message tells you the tried path. – Holger Nov 28 '16 at 12:01
  • @Holger Yip, got `fopen(settings.ini): failed to open stream: No such file or directory` however the file is there... – Nitro.de Nov 28 '16 at 12:09
  • Hmm, you could output getCWD() at this point. – Holger Nov 28 '16 at 12:16
  • @Holger Good one thank you. It seems i got an error before so the server redirects to Error 500 before calling my function so i'm in the wrong directory ;) – Nitro.de Nov 28 '16 at 12:21

0 Answers0