Welcome! » Log In » Create A New Profile

Deprecating trigger_error calls in the Tarot cards?

Posted by Yzmir Ramirez 
Deprecating trigger_error calls in the Tarot cards?
April 08, 2011 04:10PM

In some environments setting up your own PHP error_handler using set_error_handler() is not an option. Have you considered converting all the trigger_error() calls to throw exceptions?

There are 51 locations that have trigger_error calls and 23 that throw *Exception in 4.2.0.

Is that a 5.x change? Or something that could be rolled into 4.3.x 4.4.0?

Re: Deprecating trigger_error calls in the Tarot cards?
April 08, 2011 04:33PM

Some of the trigger errors are warnings intended to let developers know that they need to update their code. An exception would not be appropriate in those circumstances.

Clearly fatal errors should be converted into exceptions. Patches welcome.

Re: Deprecating trigger_error calls in the Tarot cards?
April 08, 2011 04:40PM

Hmm...what I'm trying to do is capture the bad HTML could not be handled for whatever reason. If it would be enough just to catch exceptions when in a production environment then that'll be golden.

I'm just concerned that when this is in a production environment that when there is some crazy-ass HTML passed that I couldn't log it and adjust the settings/filters accordingly.

Re: Deprecating trigger_error calls in the Tarot cards?
April 08, 2011 04:57PM

Bad HTML should never trigger a PHP warning. If it does, that is a definitive bug. (One caveat is that the DOM parser can emit errors; not our fault, but we overload the error handler temporarily to deal with this case.)

Re: Deprecating trigger_error calls in the Tarot cards?
April 08, 2011 05:00PM

Yeah I saw you guys doing that. You also do that around iconv. You did that because even when using the @ character to surpress the error messages the error handler function is still called. And then another you did to surpress the E_STRICT messages.

Very nice solutions.

Ok so for now I will go with the assumption that really crappy HTML will not generate trigger_errors(), but instead throw an Exception that can be caught.

Re: Deprecating trigger_error calls in the Tarot cards?
April 08, 2011 05:20PM

Oh yes, iconv is another bastard w.r.t. errors. You can further assume that HTML Purifier will not throw exceptions on bad HTML. It will just do its best to clean it up :-)

Re: Deprecating trigger_error calls in the Tarot cards?
April 08, 2011 05:21PM

Thank you.

Re: Deprecating trigger_error calls in the Tarot cards?
April 11, 2011 02:48PM

Just to be clear, would you be willing to consider a patch that converted all the trigger_error() calls to exceptions with a Configuration flag (default false so as to not change existing functionality)? Or would you think that would clutter up the code?

Re: Deprecating trigger_error calls in the Tarot cards?
April 11, 2011 03:05PM

I'll accept a patch that converts trigger_errors that are E_USER_ERROR can be converted to exceptions with no configuration flag. A patch that converts E_USER_WARNING trigger_errors to exceptions would be more interesting... in particular, a configuration flag won't necessarily work because a lot of this errors /come/ from the configuration handling system.

Author:
Your Email:

Subject:

HTML input is enabled. Make sure you escape all HTML and angled brackets with < and >.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

<pre><![CDATA[
Place code here
]]></pre>

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}

Message: