|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-03-07 15:29 UTC] pegasus at vaultwiki dot org
Description:
------------
After trying to run vBulletin under Master, I've found that I get Fatal Error: undefined function for a lot of functions which are normally included under PHP 5.6.
After investigating more closely, the affected functions are all included using the format:
require_once('./includes/filename.php');
If I dump the results of get_included_files(), I find that this file never gets included.
However, if I modify the line like so:
require_once('includes/filename.php');
Then all the functions are included as expected. It seems to me that require_once just skips anything starting with ./
If my include paths were configured incorrectly, I would expect a Fatal Error due to file-not-being-found.
Expected result:
----------------
Functions in ./ includes should be included.
Actual result:
--------------
Functions in ./ includes are not included.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 20:00:01 2025 UTC |
Could you please check your report_erroring level? Maybe the level is too High. In my computer I get two Warning: Warning: include_once(./2.php): failed to open stream: No such file or directory in /tmp/1.php on line 3 Warning: include_once(): Failed opening './2.php' for inclusion (include_path='.:') in /tmp/1.php on line 3 array(1) { [0]=> string(10) "/tmp/1.php" }Here is an example script that shows one way: ### a.php ### function test_function() { } ### b.php ### class Test_Class { public static function runTest() {} } ### main.php ### require_once('./a.php'); // first ./ require seems to always be included require_once('./b.php'); // eventually might not be included test_function(); Test_Class::runTest(); echo 'complete'; #### EXPECT: 'complete' ACTUAL: mostly 'complete'. Eventually, maybe Fatal error: class 'Test_Class' not found. Some more information: I cannot provide a test script that always reproduces the issue because the behavior is inconsistent. The issue seems related to the Zend Opcache, since I no longer experienced the issue when opcache was disabled for about 24 hours. However, perhaps I just didn't test vigorously enough. *Sometimes* ./ requires will simply be overlooked, as if the require line is not present in the script at all. Restarting php-fpm fixes the issue for a while. I have had this occur in different PHP scripts for different requires and the result is the same. Once it happens in one script, it will continue happening in the same script until php-fpm is restarted. The curious part, if this was related to Zend Opcache, is that even if the script is modified e.g. to check get_included_files(), the modified version of the script will still exhibit the same behavior (I'm not familiar with how Zend Opcache works -- perhaps it updates using deltas?) I have not yet tried with opcache.use_cwd=0 Perhaps it is related to this config variable being turned on. I have done some searching on this behavior, and I came across this: http://stackoverflow.com/questions/8490667/php-class-not-found-but-its-included Although the difference is that I am using ./, the end result is similar (PHP class not found even though it's included). Perhaps PHP is internally converting ./ to http://localhost/ on some occasions, although I do not know why it would. But this would give the result that I am experiencing. Just some ideas.Following the logic of my previous post, I am now able to consistently reproduce this bug in a very simple script with all files in the same local directory (no sub-directories, no symlinked directories, and none of the parent directories are symlinked anywhere as far as I know): #### 1.php #### require_once('./2.php'); function test1() { echo 'never used'; } #### 2.php #### function test2() { echo 'SUCCESS'; } #### main.php #### require_once('./1.php'); number_format('string'); test2(); exit; #### main.php attempt #1 EXPECT & ACTUAL #### Warning: number_format() expects parameter 1 to be float, string given in main.php on line X SUCCESS #### After receiving the correct actual proceed to place an "exit;" after the line that throws an error. Run main.php again. #### main.php attempt #2 EXPECT & ACTUAL #### Warning: number_format() expects parameter 1 to be float, string given in main.php on line X #### After receiving this correct actual proceed to remove the previously added "exit;" and run main.php again. EXPECT: same result as pass #1 #### main.php attempt #3 ACTUAL #### Warning: number_format() expects parameter 1 to be float, string given in main.php on line X Fatal error: Call to undefined function test2() in main.php on line Y ### Hope this helps. Basically in practice I am thinking this means that any time our real code goes through a custom error or exception handler, future calls to the second ./ include from that process will be ignored. This gives me some ideas where to start looking to workaround this issue while you are figuring out the root cause.