Bug #11915 [Fbk->NoF]: Text_Wiki doesn't work properly with some autoloaders

From: Date: Mon, 23 Mar 2009 16:59:08 +0000
Subject: Bug #11915 [Fbk->NoF]: Text_Wiki doesn't work properly with some autoloaders
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-237@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=11915&edit=1 ID: 11915 Updated by: daniel.oconnor@gmail.com Reported By: andre dot moelle at gmail dot com Summary: Text_Wiki doesn't work properly with some autoloaders -Status: Feedback +Status: No Feedback Type: Bug Package: Text_Wiki Operating System: FreeBSD Package Version: 1.2.0 PHP Version: 5.2.3 Roadmap Versions: New Comment: -Status: Feedback +Status: No Feedback Previous Comments: ------------------------------------------------------------------------ [2008-02-17 08:55:03] till If Text_Wiki is PHP4-only, you should add that to your package.xml (<max> version). ------------------------------------------------------------------------ [2007-08-28 15:50:08] pmjones Justin, one quick thought -- If you call class_exists($class, false) on PHP4, does it raise a notice or other error? If not, it seems OK to add the second param; then PHP5 will take advantage of it, and PHP4 will ignore it. Your call of course. :-) ------------------------------------------------------------------------ [2007-08-28 14:59:47] blackflash Thank you for your answer. I consider your solution while solving the problem in my code. Probably you can replace the class_exists-function with following function: function checkClass ($class) { return (false !== array_search($class, get_declared_classes())); } Just a suggestion. Hopefully support for PHP4 is suspended in near future, but that's another topic. ------------------------------------------------------------------------ [2007-08-28 14:45:01] justinpatrin That patch won't work for us as Text_Wiki is PHP4 only and the autoload parameter to class_exists is PHP5 only. We also can't change the names of the classes since Text_Wiki is stable and changing the class names would be a BC break. I would suggest for now not running your autoload code for anything starting with 'Text_Wiki_Parse'. ------------------------------------------------------------------------ [2007-08-28 06:27:13] blackflash Description: ------------ Text_Wiki doesn't work properly when using autoloaders like __autoload, since there is a class_exists call to a class that does not exist really (and where the autoloader is used). Although the implementation of the autoloader participates in that bug, I think fixing that bug will also improve Text_Wiki. Test script: --------------- <?php ini_set('display_errors', 'On'); function __autoload ($class) { require str_replace('_', '/', $class) . '.php'; } $wiki = Text_Wiki::singleton('Default'); $wiki->transform('__This does not work correctly__', 'Xhtml'); ?> Expected result: ---------------- I expected to see no error. Actual result: -------------- Warning: require(Text/Wiki/Parse/Prefilter.php): failed to open stream: No such file or directory in /usr/home/blackflash/wiki.php on line 6 Call Stack: 0.0005 51080 1. {main}() /usr/home/blackflash/wiki.php:0 0.0061 340632 2. Text_Wiki->transform() /usr/home/blackflash/wiki.php:10 0.0061 340632 3. Text_Wiki->parse() /usr/local/share/pear/Text/Wiki.php:917 0.0061 343316 4. Text_Wiki->loadParseObj() /usr/local/share/pear/Text/Wiki.php:952 0.0061 343652 5. class_exists() /usr/local/share/pear/Text/Wiki.php:1317 0.0061 343864 6. __autoload() /usr/home/blackflash/wiki.php:0 Fatal error: require(): Failed opening required 'Text/Wiki/Parse/Prefilter.php' (include_path='.:/usr/local/share/pear') in /usr/home/blackflash/wiki.php on line 6 Call Stack: 0.0005 51080 1. {main}() /usr/home/blackflash/wiki.php:0 0.0061 340632 2. Text_Wiki->transform() /usr/home/blackflash/wiki.php:10 0.0061 340632 3. Text_Wiki->parse() /usr/local/share/pear/Text/Wiki.php:917 0.0061 343316 4. Text_Wiki->loadParseObj() /usr/local/share/pear/Text/Wiki.php:952 0.0061 343652 5. class_exists() /usr/local/share/pear/Text/Wiki.php:1317 0.0061 343864 6. __autoload() /usr/home/blackflash/wiki.php:0 ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=11915&edit=1

« previous php.pear.bugs (#237) next »