From: james at safesearching dot com Operating system: redhat 7.3 PHP version: 5.0.4 PHP Bug Type: Dynamic loading Bug description: default behaviour of class_exists/__autoload() breaks PEAR classes (and others)
Description: ------------ The default behaviour of class_exists calling __autoload breaks BC for end user scripts which rely on other code outside that users control (ie PEAR classes). Many PEAR classes such as Calendar and DB_DataObject use class_exists to load other classes... Simply adding an __autoload function to a script using these classes generates a Fatal error. An option was added to allow a class_exists($name, FALSE) call to prevent an __autoload call... but as end users don't have control over things like PEAR classes, this isn't a viable fix to bug #28333. Perhaps more reasonably, class_exists should not call __autoload by default so as to maintain BC... and allow users to explicity request that behaviour with a second parameter of TRUE. Reproduce code: --------------- require_once('Calendar/Calendar.php'); $cal = new Calendar(); function __autoload($name) { require_once($name); } Expected result: ---------------- Expect no output (ie no errors). Actual result: -------------- Warning: __autoload(Calendar_Engine_UnixTS): failed to open stream: No such file or directory in /home/james/test.php on line 8 Fatal error: __autoload(): Failed opening required 'Calendar_Engine_UnixTS' (include_path='.:/usr/local/lib/php') in /home/test.php on line 8 -- Edit bug report at http://bugs.php.net/?id=33459&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33459&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33459&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33459&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33459&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33459&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33459&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33459&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33459&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33459&r=support Expected behavior: http://bugs.php.net/fix.php?id=33459&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33459&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33459&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33459&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33459&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33459&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33459&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33459&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33459&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33459&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33459&r=mysqlcfg