Reopened.
Backed out r23905 from trunk in r23980
Backed out r23957 from release branch 1.11 in r23981

Posted by Benoît Durand (intiilapa) on 2011-05-04T17:31:37.000+0000

Array

I have a problem with the commit r23905. Yes, it solves the fatal error, but the behavior is wrong. A context with the error handler is always an array.
I think the formatters, and writers can't support array for context. It's related to the problem of array in ZF-10427 for extra info when you use the simple formatter.

I recommand to delete the optional parameter errcontext of the method Zend_Log::errorHandler().

Thanks for summarizing our IRC chat from yesterday....I hadn't had a chance to do that yet :P

I completely agree. my patch was intended to prevent Zend_Log_Formatter_Xml::log from throwing a fatal error when non-string data was passed along to DOMElement. What you've described above better treats the source of the problem rather than just the symptom. Based on that, this is what I suggest"

In my opinion, this adequately treats the source of the problem (context data passed to the formatters, which can't handle it) while maintaining backwards compatibility (not changing the errorHandler() method signature and still passing $errcontext along to the original error handler (see Zend/Log.php:598))

Do you think this is an adequate solution? Are there any existing formatters which might want access to 'context'?

I've been thinking about this some more, and I think a better solution would be to modify the behavior of the existing formatters which are unable to handle the context attribute to ignore it:
* Firebug: Already covered, as context isn't included in it's output
* Simple: Already covered, as context isn't included in it's output
* Xml: Requires simple modification to ignore context:

That would assume the user of the log - be it a person or a parsing program - understands PHP serialization and can deserialize the value. My perspective is that the built-in log formatters should be simple, with more complex formatting needs implemented by the application to fit it's own use case.

The purpose of this issue, and the suggested fix, are only aimed at solving the issue at hand: usage of the XML formatter causes an exception to be raised. Discussions regarding changes to what the formatter outputs should be undertaken in a dedicated issue, on IRC, or on the mailing list.

This fix breaks functionality as described in the manual. When passing an exception to the log, the message is ignored.

The reason for this is the check on line 149 of Zend_Log_Formatter_Xml which uses www.php.net/is_scalar" rel="nofollow">is_scalar() to check if the message has to be added to the log. An Exception object is not a scalar and is therefore ignored.