I have an intermittent issue with the error include failed to open stream ...
99.9% of the time the includes works perfectly, but at peak times of the day I notice that I start getting an error appear in my php error log.
PHP Warning: include ('database.php') failed to open stream: No such file or directory
I only have one file with this include in it so I know full well its works, we have quite a few thousand requests a day with no issues, but out of these thousands of requests we seem to get around 10 a day which simply fail with the error PHP Warning: include ('database.php') failed to open stream: No such file or directory
It has driven me mad! - I have done some digging around to see what else is being requested from the IIS server at the same time and I can see that I am calling a separate php file which is unrelated to the file above. It simply counts the lines within my php error log and if there is an issue it will send an email....
I am wondering if for some reason there is some sort of file process limit that means if the error log is big enough the below code is doing something to PHP to stop it completeing file processes elsewhere such as includes ...
The basis of this code is :-
function getLines($file)
{
$f = fopen($file, 'rb');
$lines = 0;
while (!feof($f)) {
$lines += substr_count(fread($f, 8192), "\n");
}
fclose($f);
return $lines;
}
$phpcount = getLines("c:/windows/temp/php-errors.log");
I am wondering if for some reason there is some sort of file process limit that means if the error log is too large the above code struggles and PHP stops completing file processes elsewhere thus causing my includes problem ...