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

Introduction

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.

» Read full blog post

Author Message

Damien Pobel (eZ)

Friday 19 August 2011 1: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--> -->

Gaetano Giunta

Friday 19 August 2011 3:35:51 am

+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: /* */

Principal Consultant International Business
Member of the Community Project Board

Thomas ZILLIOX

Tuesday 23 August 2011 2: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,

Thomas.

--
Developer at Open Wide

Gaetano Giunta

Tuesday 23 August 2011 4:26:17 am

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...

Principal Consultant International Business
Member of the Community Project Board

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.