The Devel Module Observation Effect

The Devel module is such an indispensable part of any Drupal developer's toolkit that it's easy to forget that it does sometimes tinker with Drupal at a fairly low level. I was getting a perplexing error from an XML-RPC service I was developing as part of a Drupal module. I had written a simple testing client in Python and it was choking on the server's response, giving me the following error: xml.parsers.expat.ExpatError: junk after document element: line 11, column 0 While trying to track down the cause of the error I went so far as to temporarily hack the xmlrpc_server_output() function to dump the server response to an XML file on my hard drive. There was absolutely no junk in the document at line 11 or anywhere else, and it was at that point that it occurred to me to wonder if the Devel module might be adding something spurious to Drupal's output along the way. Sure enough, upon disabling Devel my XML-RPC method worked as expected. I'm not sure what the problem was, but in the future I'll try to remember to eliminate Devel as a culprit for unexpected behavior early on in the debugging process.

Thanks for the additional

Thanks for the additional insights, everyone. I had query logging & memory usage/load times disabled, so Morbus & Moshe probably have it. Interesting, I see that the xmlrpc_server_output() still uses header() in Drupal 7. I'll log an issue. Thanks, Moshe.

My guess is that you had

My guess is that you had devel set to either show queries or page load time at the bottom of the page. Devel spits this out after the closing html tag, hence it would break anything attempting to parse strict XML.

The problem here is not

The problem here is not devel. That function you linked to is bypassing Drupal API. It should be using drupal_set_header() to set http headers instead of header(). If it did that, then devel would recognize the text/xml header and not append its junk.

You may want to set the

You may want to set the right mime-type for your server responses - the devel.module won't do anything if it detects that the result is XML, JS, text files, etc. See "devel_shutdown" in the devel.module source (I can't remember the exact location, but that rings a bell.)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><p><div> <br><img>
  • Lines and paragraphs break automatically.

More information about formatting options

Verification
This question is for testing whether you are a human visitor and to prevent automated spam submissions.