Bug #68133 [Opn]: Fatal error: require_once/include_once when using reference
| From: | pegasus at vaultwiki dot org | Date: | Thu, 02 Oct 2014 17:38:01 +0000 |
| Subject: | Bug #68133 [Opn]: Fatal error: require_once/include_once when using reference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187798@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68133&edit=1
ID: 68133
User updated by: pegasus at vaultwiki dot org
Reported by: pegasus at vaultwiki dot org
-Summary: Fatal error: require_once/include_once
+Summary: Fatal error: require_once/include_once when using
reference
Status: Open
Type: Bug
Package: *General Issues
Operating System: Centos 6
PHP Version: master-Git-2014-10-02 (Git)
Block user comment: N
Private report: N
New Comment:
Updated title
Previous Comments:
------------------------------------------------------------------------
[2014-10-02 17:31:16] pegasus at vaultwiki dot org
Description:
------------
When require_once($x) is used inside a method that takes $x as an argument by reference, the
following error occurs:
Fatal Error: require_once(): Failed opening '0`^,' ...
If ZendOpcache is enabled, only:
Fatal Error: require_once
Checking the value of $x on the preceding line shows the correct value, and file_exists($x) on the
proceeding line shows that PHP can find the file.
If we do $y = $x; require_once($y); instead, or remove the reference, then the fatal error is
bypassed.
However, there are cases in the full use case where it is useful to change the required file within
the method, and then have external access to the new filename thanks to the reference.
Some notes: In the particular cases I've tested, the files have all been inside a symlinked
directory, but I doubt that is related since it works if the reference is removed.
Test script:
---------------
class Test
{
public static function load(&$file)
{
require_once($file);
}
}
$file = '/path/through/symlinked/directory/to/file';
// symlink is owned by root:root with 777 permissions
// target directory is owned by PHP-run-as user
Test::load($file);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68133&edit=1