|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69990 file_get_contents broken on symlinks
Submitted: 2015-07-03 18:01 UTC Modified: 2021-08-23 08:37 UTC
Avg. Score:5.0 ± 0.0
Reproduced:6 of 7 (85.7%)
Same Version:2 (33.3%)
Same OS:4 (66.7%)
From: michael dot mckeever at bosch dot com Assigned: cmb (profile)
Status: Closed Package: *Directory/Filesystem functions
PHP Version: 5.5.26 OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
15 + 5 = ?
Subscribe to this entry?

 [2015-07-03 18:01 UTC] michael dot mckeever at bosch dot com
I used:
- php 5.5.26 ts 32bit VC11 as SAPI
- apache 2.4.12 32bit VC11
- windows 7 sp1
On Windows 7 (have only tested it on Windows 7) the file_get_contents function does sometimes return false instead of returning the actual file content when used on symlinks. This happens only in conjunction with Apache. The cli versions are not affected. All types of links are affected:
- mklink
- mklink /J
- mklink /D

To repoduce the bug create the three symlink types above to a file of your choice containing the string "asdf" and apply the paths to your the test script below and use the abs.exe command (shipped with apache) to simulate 800 request with a concurency of 200 users:
abs.exe -n 800 -c 200 http://localhost/yourTestScript.php

If needed I can provide a fully virtual machine with the whole reproducable scenario in it (virtual box).

Test script:
$files =
	"file" => "C:/Development/phpdir/phpfile.txt",
	"filelink" => "C:/Development/phpdir/phpfilelink.txt",
	"dirlink" => "C:/Development/phpdirlink/phpfile.txt",
	"dirjunc" => "C:/Development/phpdirjunc/phpfile.txt",

foreach($files as $linkType => $filePath) {
	if( @file_get_contents($filePath) !== "asdf" ) {
		if( @file_get_contents("C:/Development/$linkType") === false )
			file_put_contents("C:/Development/$linkType", 0);
		file_put_contents("C:/Development/$linkType", ((int)file_get_contents("C:/Development/$linkType"))+1);

Expected result:
No files should appear in the directory "C:/Development/".

Actual result:
There are laying three files namely 'filelink', 'dirlink' and 'dirjunc' containing the number of file_get_contents failing to succeed.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-02 13:08 UTC] rombismith at cuvox dot de
We're having exactly the same issue, but not on a Win7 but on a WinServer 2008 and WinServer 2008R2.
 [2021-08-19 16:32 UTC]
-PHP Version: Irrelevant +PHP Version: 5.5.26
 [2021-08-19 16:32 UTC]
Is this still an issue with any of the actively supported PHP
versions[1]?  If so, are the link targets absolute paths?

[1] <>
 [2021-08-20 08:46 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-08-22 15:57 UTC] michael dot mckeever at bosch dot com
I'll try to reproduce this bug in a VM with Windows10.
I can't tell you if the bug is gone. Please give me approx. 3 days.
I'll report back.
 [2021-08-23 05:19 UTC] michael dot mckeever at bosch dot com
Good news!

I tested this on Windows 7 and Windows 10 with PHP 7.4.12 and Apache 2.4.46.
The bug is gone. I've not been able to reproduce the bug in any way, so this can be considered fixed.

Thank you everyone!
 [2021-08-23 08:37 UTC]
-Status: Feedback +Status: Closed
 [2021-08-23 08:37 UTC]
Thank you for checking!
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Sep 18 13:03:38 2021 UTC