ID: 45421 Updated by: [EMAIL PROTECTED] Reported By: rpeters at icomproductions dot ca -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: CentOS 4.3 PHP Version: 5.2.6 New Comment:
There is nothing wrong with PHP here, its working as intended. I suggest you stop relying on __FILE__ if you intend to use an opcode cache. Previous Comments: ------------------------------------------------------------------------ [2008-07-02 21:54:35] rpeters at icomproductions dot ca Related to APC Bug# 14055 http://pecl.php.net/bugs/bug.php?id=14055 ------------------------------------------------------------------------ [2008-07-02 21:53:23] rpeters at icomproductions dot ca Description: ------------ Since __FILE__ is defined at compile-time, it means that files that "change location" (eg: are renamed, or hard-linked with multiple filenames) execute incorectly when pre-compiled. This is especially evident with op-code caches such as APC. So __FILE__ either needs to be determined at runtime, or a runtime accessible alternative needs to be provided. I propose $_SERVER['PHP_FILE'], and would like documentation updated to recommend people use it rather than __FILE__. Obviously, __DIR__ would need the $_SERVER['PHP_DIR'] variable for the same reasons. Reproduce code: --------------- CURRENTLY: /1/test.php: <?php require(__DIR__ . '/testDest.php'); ?> /2/test.php created by "cp -l ../1/test.php" /1/testDest.php: <?php echo 1; ?> /2/testDest.php: <?php echo 2; ?> PROPOSED: /1/test.php: <?php require($_SERVER['PHP_DIR'] . '/testDest.php'); ?> /2/test.php created by "cp -l ../1/test.php" /1/testDest.php: <?php echo 1; ?> /2/testDest.php: <?php echo 2; ?> Expected result: ---------------- /1/test.php displays "1", and /2/test.php displays "2" Actual result: -------------- CURRENTLY: When running APC, both scripts will return the results of whichever one you hit first. PROPOSED: When running APC, /1/test.php displays "1", and /2/test.php displays "2" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45421&edit=1