When devel_shutdown() is called and prints it output, it puts this stuff *outside* <html> This causes all sorts of strange oddities with jQuery as it manipulates the DOM.

Ideally devel module's output should goto into $closure which is filled by calling hook_footer().

Moving the devel_shutdown() into hook_footer() fixes this.

Proposed patch moves all of this into devel_footer() to fix this behavior.

CommentFileSizeAuthor
#3 t_8.patch1.64 KBm3avrck
t_7.patch1.9 KBm3avrck

Comments

moshe weitzman’s picture

Status: Reviewed & tested by the community » Needs work

there are important queries that happen after hook_footer such as sess_write(). i am open to any ideas which let preserve those queries and still emit valid html.

moshe weitzman’s picture

Perhaps we send the queries down as a .js array and then inject them into the page before . that would be valid at least. not sure if it is worth the complexity though.

m3avrck’s picture

StatusFileSize
new1.64 KB

Ok yeah, here is a JS approach. The script is outside the HTML but it fixes the problem of weird displays.

m3avrck’s picture

Status: Needs work » Needs review
moshe weitzman’s picture

do folks think this is a worthwhile change? devel has cadded its output here since the beginning of time. is the fix worse than the bug?

m3avrck’s picture

Moshe, read my email and check the DR... this is needed because of AJAX :-)

m3avrck’s picture

Try this: grab devel module + simplemenu. Then turn on query logging, notice how you get a set of queries at the top of the page, ruining things, and one at the bottom. Strange right?

Well apply my patch above to devel. Now you see there are 2 sets of queries at the bottom: 15 queries and 8.

WTF? Why are they different? And why the hell is only 15 queries in the source to the page and the other 8 not?

Give up? Here's a clue: AJAX.

SimpleMenu makes an AJAX call per page. Guess what? That is a Drupal bootstrap and devel registers devel_shutdown() so it logs the queries. But this AJAX call is within another page that takes 15 queries to render.

Ahah! That's why you get 2 sets.

So that patch is needed when you're running AJAX sites, otherwise you'll get queries appearing wherever your AJAX calls are.

moshe weitzman’s picture

Status: Needs review » Needs work

thanks ted. i installed simplemenu and i get it now. we already suppress devel output for most of these ajax requests because the responses are in javascript (specifically, a JSON object). same for rss feed responses note how devel_exit() won't print anything if http headers are text/xml or text/javascript. whats needed here is a way for simplemenu to state that the current request is not a full page, but rather an AHAH response and thus should not be touched. i don't want the query info coming down in the first place.

for now, I propose inventing a new variable like $GLOBALS['devel_suppress'] and if that is TRUE, devel doesn't print junk. So you would set that variable just before your exit call in simplemenu_get_menu();

m3avrck’s picture

Hmm, that's an interesting idea.

However, at first I thought this was a bug, now I see how powerful this is. It took 8 queries for my AJAX call, that is useful stuff!!!

Why would I want to surpress it?

With the proposed patch it consolidates everything (basically anytime devel_shutdown is called it prepends all output to the body).

Thoughts?

moshe weitzman’s picture

That won't work. The queries from the AHAH request are stuck at the bottom of an invalid page. There is no BODY tag to append them to. This takes a little while to understand whats going on. The patch you proposed would only move the queries from the original request, not the AHAH response.

m3avrck’s picture

Well not entirely... I saw the set of queries needed to run that AJAX request posted to the main page at the bottom -- hence the 2 sets of queries, 15 and 8.

While the AHAH page is never really rendered anywhere, it is printed to the screen. It is during this printing that the JS is printed as well so that it can the be appended to the calling page body.

moshe weitzman’s picture

Title: devel_shutdown() should be in hook_footer() » put querylog before </body> in DOM and properly place the querylog for AHAH requests
Status: Needs work » Fixed

committed. thx.

Anonymous’s picture

Status: Fixed » Closed (fixed)
dww’s picture

Status: Closed (fixed) » Active

this patch seems to have broken devel.module for anonymous users since drupal_add_js() is undefined in hook_init() if you're anonymous. :( see http://drupal.org/node/126419

moshe weitzman’s picture

Status: Active » Fixed

quick fix in place. i just removed that line. hopefully won't break other stuff

Anonymous’s picture

Status: Fixed » Closed (fixed)