php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48959 is_readable() and filezise() do not return correctly
Submitted: 2009-07-17 12:10 UTC Modified: 2009-11-02 01:00 UTC
From: trutas dot ctx at gmail dot com Assigned: pajoye (profile)
Status: No Feedback Package: Filesystem function related
PHP Version: 5.3.0 OS: win32 - Windows Server 2003 x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: trutas dot ctx at gmail dot com
New email:
PHP Version: OS:

 

 [2009-07-17 12:10 UTC] trutas dot ctx at gmail dot com
Description:
------------
is_readable() returns false for temporary file (just created) "C:\WINDOWS\Temp\dom373.tmp" and filezise() fails too.

fopen() and get_file_contents() both work for the same file.

as a workaround i'm using fopen() instead of is_readable() and 
fseek($fopen_instance, 0, SEEK_END); instead of filesize()

Reproduce code:
---------------
//temporary location
$resolved_url = tempnam(DOMPDF_TEMP_DIR, "dompdf_img_");
//get source
$image=my_file_get_contents("http://9tree.net/favicon.ico");
//save it
file_put_contents($resolved_url, $image);

//tests
if(is_readable($resolved_url)) print "file readable, ";
if(filesize($resolved_url)) print "filezise found.\n";

die("all done.");

Expected result:
----------------
file readable, filezise found.
all done.

Actual result:
--------------
all done.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-17 15:08 UTC] trutas dot ctx at gmail dot com
Just tested - file_exists() returns false incorrectly too.

I?ve worked around it all with checking for fopen($file, 'r') and forcing file_get_contents() - it works, file exists, is readable and returns the content.
 [2009-07-17 15:34 UTC] pajoye@php.net
Cannot reproduce on 2k8, vista and win7. Pls note that I replaced the my_file_... with the normal file_get_contents function.

Can you paste a working script pls?
 [2009-07-17 16:09 UTC] trutas dot ctx at gmail dot com
The environment could be the problem here,
 
I'm using Windows 2003 x64 with PHP x64 via fastcgi.

These are two IIS Servers with load balancer and a separate cluster 
that serves the actual run files.
PHP is installed on D:\PHP on each IIS machine.

The problem came up using the library dompdf - it saves document 
images content to temporary files in order to build the final pdf 
document.

I've reduced the problem to the test code i've attached. 
DOMPDF_TEMP_DIR is /tmp and writes to C:\Windows\tmp ...

- Please note that this problem does not happen in local folder to the 
execution base (eg. "tmp_sub_folder/" ) - this only happens in the 
system tmp folder in this setup.

This is the same setup environment as the one reported in the bug 
48852 (about file_put_contents)



Regards,
 [2009-08-10 15:27 UTC] pajoye@php.net
I have no idea what DOMPDF_XXXX is and how it is used.

Please provide a standalone script I can use to reproduce your problem, as well as which paths are used by the script.

"- Please note that this problem does not happen in local folder to the  execution base (eg. "tmp_sub_folder/" ) - this only happens in the  system tmp folder in this setup."

It looks like a permission problem to me.

 [2009-08-10 17:30 UTC] trutas dot ctx at gmail dot com
I'm sorry for the DOMPDF_TEMP_DIR,

Initially this problem was discovered when using dompdf in this 
environment - file_get_contents was a proxy workaround.

I have fully tested this version:

Reproduce code:
---------------
<?php
//temporary location
$resolved_url = tempnam("/tmp", "test_");
//get source
$image=file_get_contents("http://9tree.net/favicon.ico");
//save it
file_put_contents($resolved_url, $image);

//tests
if(is_readable($resolved_url)) print "file readable, ";
if(filesize($resolved_url)) print "filezise found.";
?>

In Unix/Win32 it works perfectly.

This is only happening in Windows Server 2003 x64 IIS 6.0 where 
tempnam("/tmp", "test_") returns something like 
"C:\WINDOWS\Temp\tes20FB.tmp".

in the case of filesize i get a warning - "stat failed for 
C:\WINDOWS\Temp\tes20FB.tmp ..."

Regards,
Carlos
 [2009-09-01 19:19 UTC] garretts@php.net
>> I'm using Windows 2003 x64 with PHP x64 via fastcgi.

I have a few questions:

1) Does this happen when you use the 32bit PHP binary on Windows 2003?

2) Does this only happen running under IIS (ie, can you replicate the results from the command line?).

3) What user is your app running as?

G
 [2009-10-25 22:21 UTC] pajoye@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-11-02 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC