Welcome! » Log In » Create A New Profile

Prefix all the includes (and included includes) with the PREFIX already defined...?

Posted by mike503 

I love htmlpurifier. I think it will help me cut down on the amount of garbage our users post.

However one issue I'd like to fix:

Inside of HTMLPurifier.php you do this: // constants are slow, but we'll make one exception define('HTMLPURIFIER_PREFIX', dirname(__FILE__));

Why not use that then in front of all the requires?

instead of: require_once 'HTMLPurifier/ConfigSchema.php';

use: require_once HTMLPURIFIER_PREFIX.'/HTMLPurifier/ConfigSchema.php';

and inside of all the includes too...

then it can truly be self contained anywhere. right now it's only partially capable and the include path hack in the .auto.php file does not work for me. that define is there already, why not use it? :)

Re: Prefix all the includes (and included includes) with the PREFIX already defined...?
March 26, 2008 12:01AM

That's a very interesting setup you have there! I've never heard of include path not working before; what host are you using?

I don't recall a specific reason for not adding the prefix; probably to save keystrokes and for some vague performance reason. Probably more the former.

With the newer version, there's a file that generates an include stub that includes all of the necessary files with HTML Purifier, there's also an autoloader. Probably would be much easier to sneak in the prefix; I'll see if I can add support for that.

it's my own hosting setup. i don't rely on php's include path, it's not even defined in my php.ini (which could be the issue, maybe since it's not defined [even though it still looks like it has the normal ones hardcoded], it can't expand off of it properly... oh well)

however, i don't see why not, it's recommended by everyone that giving absolute paths is the best for includes or requires. also require_once is opcode-expensive (i think using a bytecode cache like APC solves a lot of that) but if it can move to using require instead of require_once that might help save more overhead too...

was surprised to see even 3.0 hasn't done that yet, especially since it creates a constant with the path already! :)

Re: Prefix all the includes (and included includes) with the PREFIX already defined...?
March 26, 2008 07:16AM

Ah, ok; you'll really be interested in the performance optimizations in 3.1 :-)

Sorry, you do not have permission to post/reply in this forum.