activeselect should set a text/javascript header on json pages

Arancaytar - January 21, 2008 - 09:12
Project:Active Select
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Arancaytar
Status:needs review
Description

A taxonomy active-select menu has recently stopped working on my site whenever I was logged in as admin. After some confused debugging, I traced this to the following message in the JS Error Console:

Error: missing ) in parenthetical
Source File: htt p://blades.ermarian.net/misc/drupal.js
Line: 131, Column: 197
Source Code:
({ "field-category-children": { "options": { "0": { "value": "---" }, "3": { "value": "G", "selected": true }, "5": { "value": "PG" }, "4": { "value": "R" } }, "multiple": "" } }<div class="dev-query">Executed <em>17</em> queries in <em>82.4

It's fairly obvious that the query timer output is breaking the page.

I'm not sure if this module conflict ought to be here or in activeselect - perhaps avoid sending query info if the content type is not set to html? Or perhaps activeselect should exit() after sending to prevent the devel module from displaying stuff.

#1

moshe weitzman - January 21, 2008 - 17:15
Project:Devel» Active Select
Version:5.x-1.x-dev» 5.x-1.x-dev
Component:devel» Code

activeselect needs to send set a header for text/javascript along with the json. see druapl_set_header()

#2

Arancaytar - January 21, 2008 - 18:01
Title:Devel's query timer breaks JSON pages» activeselect should set a text/javascript header on json pages
Assigned to:Anonymous» Arancaytar
Status:active» needs review

Ah, k. Didn't see that activeselect never actually set its content header. I'm patching forthwith.

Note that the actual error in this case does not strictly speaking lie with activeselect, but with content_taxonomy_activeselect, which provides hierarchical taxonomy selection and has its own JSON page callback.

However, as activeselect provides a central "no cache" header function that all these page callbacks are supposed to use, it shouldn't hurt to send a text/javascript header by default. As header() replaces previous headers by default, there is no danger of trying to send duplicate content types either.

Addendum: Please note that the other header() calls should strictly speaking be drupal_set_header() calls. That is a matter for another issue, however.

AttachmentSize
activeselect_json_header-212465-2.patch 712 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.