From: aarondoom at cookiedoom dot com Operating system: Gentoo Linux 1.6.12 PHP version: 4.3.11 PHP Bug Type: Unknown/Other Function Bug description: Functions not usable when "require"'d from parent later in a child.
Description: ------------ When a parent document requires a source file and then requires a second file that requires the same as above it cannot access the functions in the already required file from the parent, but cannot use or redefine the functions that are required. Using code that "if (!defined("_FUNCS_INC_")) { define("_FUNCS_INC_", true); function Bleh($Bloop) { return $Bloop; } } // _FUNCS_INC_". This is a problem because the _FUNCS_INC_ is defined as well as the functions defined inside of the scope of the document though function_exists will return false and calling the function will obviously fail for that reason, I cannot redefine those functions in the sub-document or I'll get "Cannot redefine function bleh"... even though I can't use it. Though it is easy enough to work around the issue (With the "if (!defined())" stuff require_once doesn't even make it work BTW) I'm reorganizing several hundred files, at least 1/3 of which are includes which need to be re-ordered. Any help would be greatly appreciated. Reproduce code: --------------- <?php // Funcs.inc if (!defined("_FUNCS_INC_")) { define("_FUNCS_INC_", true); function Bleh() { printf("Blah\n"); } } // _FUNCS_INC_ ?> <?php // DB.inc require("Funcs.inc"); Bleh(); ?> <?php // Header.inc require("Funcs.inc"); require("DB.inc"); Bleh(); // Won't error ?> Expected result: ---------------- Blah\n Blah\n Actual result: -------------- Fatal error: Call to undefined function: bleh() in /var/www/localhost/includes/DB.inc on line 3 -- Edit bug report at http://bugs.php.net/?id=33579&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33579&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33579&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33579&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33579&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33579&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33579&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33579&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33579&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33579&r=support Expected behavior: http://bugs.php.net/fix.php?id=33579&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33579&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33579&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33579&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33579&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33579&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33579&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33579&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33579&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33579&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33579&r=mysqlcfg