Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All

Bug #14453 Text_Wiki outputs warnings when autoload is enabled
Submitted: 2008-08-04 12:26 UTC
From: sagi Assigned: till
Status: Verified Package: Text_Wiki2
PHP Version: 5.2.2 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2008-08-04 12:26 UTC] sagi (Sagi Bashari)
Description: ------------ Text_Wiki uses class_exists to check whether it needs to include a class file. However, such usage makes PHP dispatch an autoload call for the class, which may generate a warning if the autoload is not looking inside the PEAR path. This can be fixed by passing 'false' as a second parameter for class_exists, which will prevent the autoload call, eg. class_exists($class, false).

Comments

 [2008-08-04 14:58 UTC] justinpatrin (Justin Patrin)
Except that the second parameter is specific to PHP5 and this package still supports PHP4, so it can't be added without causing another kind of warning. I suggest you add support to your autoload function for loading PEAR classes.
 [2008-08-04 18:56 UTC] sagi (Sagi Bashari)
I tried to add autoloader support for PEAR classes, but it doesn't really solve the problem because Text_Wiki tries to load some files which don't match the standard PEAR directory structure. For example, it needs to load Text_Wiki_Parse_Prefilter, but this class resides in Text/Wiki/Parse/Default/Prefilter.php, so the autoloader can't find it. BTW, AFAIK PHP does not generate warnings when passing too many parameters to a function.
 [2008-08-07 14:13 UTC] berdir (Sascha Grossenbacher)
PHP generates such warnings, but only for internal functions: Simple example: Warning: class_exists() expects at most 2 parameters, 3 given in Command line code on line 1 So, this is unfortunatly not possible.. As a short fix, I'd suggest to ignore text_wiki class in your autoload function. The only way to really fix this is probably by adding dummy files to text_wiki, which "forward" the include call, as renaming the files would break backward compability...
 [2008-10-26 05:58 UTC] cweiske (Christian Weiske)
The problem here is that every renderer/type (Dokuwiki, bbcode, ...) defines the same class names. This makes it easy to use them once they are loaded, but has two drawbacks: a) Autoloaders cannot load the files because they do not follow the PEAR directory structure b) One cannot parse/render multiple formats in one go, because the classes already exist. So the proper way would be to give the classes the correct name and modify the functions loading/using them to respect their prefix.
 [2011-03-20 00:32 UTC] till (Till Klampaeckel)
-Assigned To: +Assigned To: till
@Christian: I'll attempt fixing it, can you explain where this is is the case? To me it looks like the class names have been fixed already. I don't see the same class names from different renders (or maybe didn't look hard enough). Since autoload is more or less a PHP5 feature, is it save to add an if with version compare? Till
 [2011-03-20 03:26 UTC] till (Till Klampaeckel)
-Package: Text_Wiki +Package: Text_Wiki2
Nevermind, found plenty. Moving this to Text_Wiki2. It's unfixable on Text_Wiki.