|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-07-11 12:32 UTC] falk dot aaron85 at gmail dot com
Description:
------------
I'm using php 7.0.9NTSx64 on a IIS 8.5 (Windows 2012 R2) to provide a TYPO3 website. Unfortunately, randomly occurs a "No such file or directory" error on calling file_get_contents() for a local static file (e.g. svg images).
Before the file_get_contents() call a file_exists() call is executed to verify that the file exists and it does indeed:
I can reproduce the error by clearing the backend caches of TYPO3 and then opening 40 tabs of the List menu.
In the frontend the error occurs randomly, maybe when multiple clients are using the website, but i cannot reproduce it.
Another strange thing is, that when i clear the application pool on IIS, the error will not occur for a few hours.
I already tried to use different PHP versions (5.x-7.x with and without fastCGI), disabling symbolic links, ... but nothing resolved the problem.
The error only occurs under Windows machines, not under Linux or MacOS. You're also able to reproduce it in shell.
Test script:
---------------
1..5 | ForEach-Object { Start-Job { c:\phptest\php-ts\php.exe -f c:\phptest\test.php } } | Out-Null
Get-Job | Receive-Job
Get-Job | Remove-Job -Force
<?php
ini_set('display_errors', 1);
error_reporting( E_ALL );
$path = '/path/to/file.zip';
for ($i = 0; $i < 100; $i++) {
echo "File Exists" . PHP_EOL;
var_dump(file_exists($path));
echo "FileSize".PHP_EOL;
var_dump(filesize($path));
echo "RealPath".PHP_EOL;
var_dump(realpath($path));
echo "FileGetContents".PHP_EOL;
var_dump(strlen(file_get_contents($path)));
echo "Fopen".PHP_EOL;
var_dump(fopen($path, 'rb'));
echo PHP_EOL . PHP_EOL;
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 03:00:01 2025 UTC |
Still no luck. I've changed your code to a bit shorter version <?php ini_set('display_errors', 1); error_reporting( E_ALL ); $path = 'C:\path\to\file'; for ($i = 0; $i < 100; $i++) { if (!file_exists($path)) { die("Doesn't exist"); } if (!file_get_contents($path)) { die("No content"); } } echo "all clean"; and used up to 32 processes, but all i get is "all clean" outputs. You told you've used other PHP versions, have you tried latest versions or just some? Also, does this reproduce on another machine? Thanks.