This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » Discussions » Turning off debug for xml output

Friday 19 August 2011 9:52:34 am - 4 replies

» Read full blog post


So I'm trying to debug a site which has ajax calls to a module that serves xml.  Of course the debug output appended to the xml breaks it.  I've had this problem before but I never bothered looking closer at it until now.

Friday 19 August 2011 10:30:46 am

If a custom module/view is used to generate XML you can use to eZDebug::updateSettings() to change the debug behaviour for this view only. Another solution is to put the following code in the XML output so that the full debug is commented and does not break the XML :

<!-- <!--DEBUG_REPORT--> -->

Modified on Friday 19 August 2011 10:32:10 am by Damien Pobel (eZ)

Friday 19 August 2011 12:35:51 pm

+1 for adding double comment marks in your templates. Do note though that if your debug output does contain charcters that are not valid xml entities, the xml will be malformed anyway.

Also note that you can use the same techinque when producing json output, by wrapping the DEBUG_REPORT tag in js comment tags: /* */

Tuesday 23 August 2011 11:45:31 am

Hi Steven !

Thanks for this idea. I think it's really simpler & lighter than adding comment debug in every AJAX view.

I tried your technique on a project. It works well, but I had to modify your code :

if ( preg_grep('@Content-Type: (text|application)/(xml|json).*@', headers_list() ) )
        return null;

See you,


Tuesday 23 August 2011 1:26:17 pm

Btw, eZ also supports filtering the final output of the page, see OutputSettings/OutputFilterName.

You could tehn use a regexp to remove the debug output when in json/xml content. A bit of a waste of resources, as you'd be generating the debug report to remove it later on, but at least you would not have to hack the index file...


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from