php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52398 Include() sporadicly fails when is_file()/is_readable() == TRUE
Submitted: 2010-07-22 02:30 UTC Modified: 2010-07-23 14:48 UTC
From: smiths73v3 at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.3.2 OS:
Private report: No CVE-ID: None
 [2010-07-22 02:30 UTC] smiths73v3 at gmail dot com
Description:
------------
Running Joomla with lighttpd, fastcgi, mysql.
About 1 in 5 loads of alternating pages, an error is encountered where
is_readable($path) is true, but the include fails. The file system has
plenty of space, the file does exist, permissions are correct, and 
the file is loaded successfully the other 4 times.

The code snippet below will sometimes fail with "Include failed"
and then a subsequent reload of the page will succeed with "Include Success"
-----------------------------
$path = 'somefile.php';

if (is_readable($path)) 
{
    $retval = include $path;
    echo '<span class="note">Include retval='.$retval.'</span>';
    if ($retval == '')
    {
      echo '<span class="note">Include failed</span>';

    }else
    {
      echo '<span class="note">Include Success</span>';
    }
} else 
{
        echo '<span class="note">File not readable</span>';
}

Test script:
---------------
$path = 'somefile.php';

if (is_readable($path)) 
{
    $retval = include $path;
    echo '<span class="note">Include retval='.$retval.'</span>';
    if ($retval == '')
    {
      echo '<span class="note">Include failed</span>';

    }else
    {
      echo '<span class="note">Include Success</span>';
    }
} else 
{
        echo '<span class="note">File not readable</span>';
}

Expected result:
----------------
Include Success

Actual result:
--------------
Include failed

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-22 02:38 UTC] smiths73v3 at gmail dot com
The failure generates the following output in the lighttpd error log when debug.log-request-handling = "enable"
-------------------
2010-07-18 23:37:29: (mod_fastcgi.c.2711) FastCGI-stderr: 
    PHP Warning:  
include(/var/www/components/com_php/files/special_include.php): 
    failed to open stream: No such file or directory in 
/var/www/components/com_php/php.php on line 50
-------------------

Downgrading the system to 5.2.10 (karmic) is a workaround for the issue.
 [2010-07-23 12:27 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2010-07-23 12:27 UTC] aharvey@php.net
This seems fairly unlikely to be a PHP bug. One in five includes
failing on 5.3 installs would result in an awful lot of bug
reports. :)

I'd suggest following this up with one of the support channels,
although a wild guess would be that one of your FastCGI instances
is getting its environment or working directory clobbered somehow.
 [2010-07-23 14:48 UTC] smiths73v3 at gmail dot com
I agree this does look like an environment thing, however there is evidence to 
the contrary.

"is_readable()" for the file succeeds immediately prior to the include failure.  

 A simple rollback from 5.3 to 5.2 resolved the issue, nothing else was changed 
in the environment. Many other includes function properly without any issues, so 
this is not as simple as 1:5 includes fails. There must be some other 
contributing factor. I suspected an fd shortage, but increasing the fds and 
checking the environment showed this was not the case.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Aug 09 10:01:24 2020 UTC