This is a rather tricky issue, but I've managed to figure out the following:
- When working in a unsaved clone of a node (from the node_clone module), ie. on the path node/261415/clone (where 261415 is the node we're cloning from), when you select a term with children, causing a POST to hierarchical_select_json, the POST request causes a PHP fatal error, which in turn returns no data and causes the Hierarchial Select interface to go into infinite stopwatch mode.
- This is due to
hierarchical_select_json() passing boolean FALSE to drupal_render (which tries to += its parameter to an array), which in turn gives PHP Fatal error: Unsupported operand types in /var/www/drupal/drupal6/includes/common.inc on line 2827.
- The FALSE originates from
_hierarchical_select_get_form_item(), since it tries to find an element of the name of 'taxonomy[4]' (in this case) in the form that's returned from drupal_retrieve_form, and since it finds no elements of that name, it returns FALSE.
- The reason that it finds no such element is that the form in this case is totally devoid of fields. When passed through dpm(), it looks like this: http://skitch.com/mikl/bymh4/ .
- The reason the form is empty is probably because there is something wrong with the data passed along from
$storage['parameters'], but I have yet to figure out what it is.
I have not yet managed to find a decent workaround for this, just bypassing drupal_render when no element is found will just cause Hierarchical Select to fail in a different way, since the HTML snippet it expects is not returned.
There is perhaps more digging to be done, or perhaps a decent workaround would be to generate a new form with the same $form_id, but leaving out the state from $storage, but now I really need to sleep :)
Comments
Comment #1
wim leersmikl's client, Peytz & Co, will be sponsoring this patch. Thanks mikl and Peytz & Co!
I'll work on this on Monday.
Comment #2
wim leersmikl has asked me to also make Hierarchical Select handle errors better (i.e. failed/erroneous callbacks to the server).
Thanks to Peytz & Co, who's sponsoring this patch, I managed to solve the problem and make HS more informative when an error occurs.
To solve the actual problem, a patch to the Node Clone module was necessary:
To make Hierarchical Select more informative in case of errors, I extended the JS quite a bit. It seems jQuery 1.2.6 behaves very differently in Safari and Firefox, which made me wonder what was going on. I got it working in the end. When an error occurs, the
Drupal.HierarchicalSelect.throwError(hsid, message)gets called and:alert().<none>option, if it's present.Comment #3
wim leersI also created an issue in the Node Clone issue queue and attached the patch: http://drupal.org/node/372185.
Comment #4
wim leersComment #5
wim leersComment #7
pwolanin commentedbetter patch for Node clone posted here: http://drupal.org/node/372185#comment-3217398
Comment #8
wim leersThanks pwolanin, and great that it's gotten committed! :)
Comment #9
CSoft commentedhierarchical_select 6.x-3.7 + node_clone 6.x-1.x-dev
When the cloning node and select the term, hierarchical_select.js gives an error:
"Received an invalid response from the server."
After updating the page:
warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'node_form' not found or invalid function name in \includes\form.inc on line 377.
warning: uasort() expects parameter 1 to be array, boolean given in \includes\common.inc on line 2944.
How can solve this problem? :(
Comment #10
kenorb commented