Welcome! » Log In » Create A New Profile

PHP5-strict version is not E_STRICT compatible

Posted by Evolic 
PHP5-strict version is not E_STRICT compatible
October 25, 2007 06:59PM

On Downloads page I have noticed that there is special version for PHP5 (HTML Purifier 2.1.2 PHP5-strict), which should prevent from complaining with E_STRICT warnings. I'm using framework ZNF (http://zeronotice.org/), which has capability to run in a E_STRICT environment.

Unfortunately mentioned version of HTML Purifier still make E_STRICT warnings. I decided to look up the code and I have found that there are: - var instead of public, private or protected access types - all (maybe the most) functions has not defined access type, although some of them has it in function description.

I replaced all "var" to public, and then I replaced "public" to "private" or "protected" where you described it. I also added "protected/private", to some functions where you also describe it.

Then I decided to test it and there was one problem: - In HTMLPurifier_EntityParser class, function substituteNonSpecialEntities() is described as protected, but it is used in HTMLPurifier_Lexer class, on line 336. So this function should be public, not protected.

Now everything is fine and works good. The only thing I had to do was increasing memory limit from 8MB to 16MB, because script failed when I tried to load HTMLPurifier.auto.php

Best regards, Tomasz Kuter

Re: PHP5-strict version is not E_STRICT compatible
October 25, 2007 07:06PM

Hi, thank you for sending information about your experiences E_STRICT'ifying HTML Purifier.

After doing a little research, I've found that the PHP5 E_STRICT version of HTML Purifier only fixes run-time E_STRICT errors, not compile time errors (we adjust error_reporting at run time, since my development server runs a bit of legacy software so it's not feasible to simply switch in php.ini). It will stay that way for now, because maintaining two parallel branches with PPP declarations for everything is too difficult.

Once PHP4 is superseded, HTML Purifier will transition to a PHP5-only codebase, at which point there certainly will be no E_STRICT errors at all.

Re: PHP5-strict version is not E_STRICT compatible
October 25, 2007 09:17PM

I'm testing it on my own Linux, so I can setup PHP as I want :) There is not so many changes :)

I have version 2.1.2 from tar.gz archive. I can make patch to current trunk version. I have also PHP4 on the same machine, but my application won't work with PHP4.

I have tested changed HTML Purifier outside my application and it won't work with PHP4. PHP4 wants "var" instead of "public", "protected" or "private" :(

PHP4 is too old for me :>

I didn't checked what are the differences between HTML Purifier standard and strict versions.

I understand your decision: HTML Purifier has many classes and managing it is a bit hard I think. But someday you should move fully to PHP5 without using some tricks :)

I think you could release on your web page modified version (it maybe useful for someone)?

Re: PHP5-strict version is not E_STRICT compatible
November 24, 2007 11:50PM

Hi, Tomasz, you may find it interesting to know that the HTML Purifier code in the trunk has been converted completely to PHP 5. It turns out that the var E_STRICT warnings where removed 5.1.3; the latest code runs perfectly on all currently released versions of PHP 5, hurrah!

While I don't plan on a new release until January 2008 (when PHP 4 is officially deprecated by the PHP group), feel free to grab a snap or check out the latest code from the repository.

Re: PHP5-strict version is not E_STRICT compatible
November 25, 2007 05:39AM

Hi,

It's nice to see, that some of PHP developers move their projects to PHP5.

As you wrote PHP4 is deprecated and truly speaking new PHP6 is coming (I hope it will be released until the end of 2008 year) I made patch for version 2.1.2. Because of no free time I didn't the same for 2.1.3 version. Now I know there wouldn't be such need in the next versions :)

Does new version work with PHP4? I remember you didn't want to create separate branches for PHP4 and PHP5.

I'll check the latest code the next days.

Re: PHP5-strict version is not E_STRICT compatible
November 25, 2007 09:14AM

The new version does not work with PHP 4.

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