Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Title says almost all of it.
The solution is simple:
+// Some modules store the file that is needed in an AHAH callback. For example
+// in the case of Hierarchical Select, the node form is rebuilt in an AHAH
+// callback, which obviously requires the node_form() function to be present.
+// Hierarchical Select knows which file is necessary by looking at the file
+// for the current menu item.
+// However, when the node form is presented through the Node Clone module, a
+// different file is used: clone.pages.inc. So in order to allow the function
+// for the node form to be found, we have to include the node.pages.inc file!
+require_once(drupal_get_path('module', 'node') . '/node.pages.inc');
Patch attached. Patch was sponsored by Peytz & Co, to ensure Hierarchical Select's compatibility with the Node Clone module: http://drupal.org/node/355226.
Comment | File | Size | Author |
---|---|---|---|
#6 | 372185-better-node-pages-require-D5-6.patch | 1.1 KB | pwolanin |
#5 | 372185-better-node-pages-require-5.patch | 1.08 KB | pwolanin |
node_clone_ahah_callback_support.patch | 1.14 KB | Wim Leers |
Comments
Comment #1
pwolanin CreditAttribution: pwolanin commented@Wim Leers -
I'm not totally clear from the description why this existing code does not prevent the problem:
If we want to always include node.pages.inc, then this include_once() must be removed, I think.
Comment #2
dawehnerI don't know why, but this patch works for me.
Comment #3
askibinski CreditAttribution: askibinski commentedI confirm the patch works but the default include doesn't.
Not sure why because clonde_node_check does include the .inc. Probably a matter of order when includes are called?
Comment #4
pwolanin CreditAttribution: pwolanin commentedThis fix still looks like a bit of a hack to me - and patch still needs work per above comment.
I think the real fix is that the require might have to be inside the form building function to accommodate this case.
Comment #5
pwolanin CreditAttribution: pwolanin commentedLike this.
Comment #6
pwolanin CreditAttribution: pwolanin commentedversion for Drupal 5x-2.x
Comment #7
pwolanin CreditAttribution: pwolanin commentedoops - #6 is garbage - guess I confused my CVS checkouts.
committed #5.
Comment #9
ayalon CreditAttribution: ayalon commentedI have to reopen this issue, because the patch provided in #5 does not work as expected.
I'm using Heirarchical Select 3.4 and the latest Node Clone 6.x-dev.
Using the patch profided in the first post solved the problem completely. The patch provided by pwolanin has no impact on the problem using Hierarchical Select one cloned node form.
Reproduce:
- Install modules as described above
- Create a node Type with at least 3 hierarchies of taxonomy
- Select a taxonomy and save the node (3d level)
- Clone the node and try to select a different third level taxonomy.
- Boom: php exception and WSOD
Comment #10
pwolanin CreditAttribution: pwolanin commentedCan you explain the code flow. I guess we could go with the original patch, but I'd rather not if we have a more specific way to include it.
Comment #11
ordually CreditAttribution: ordually commentedI can confirm the issue, as documented in #9. I don't get a WSOD but do see pop up javascript death errors when attempting to change HS taxonomy on the cloned node. Applying the WimLeers patch cured it.
Comment #12
baff CreditAttribution: baff commentedWhen cloning a node which includes HS I have no problem in cloning as long as I do not change the HS values. If I want to modify HS values I have to first save the node, edit it again and then it works. I do not us a patch.
Comment #13
pwolanin CreditAttribution: pwolanin commentedI'm going to "won't fix" the issue unless someone can explain the code flow to me and when the include needs to happen.
Comment #14
pwolanin CreditAttribution: pwolanin commentedComment #15
markdorisonI am experiencing this issue. The original patch fixes the issue for me. I believe it has something to do with the fact that the callback that the Hierarchical Select module is using is not invoking the clone_node_prepopulate() function which currently is being used to include node.pages.inc. Maybe someone with a better understanding of how HS's callback works can weigh in with some more details.
Comment #16
nikitas CreditAttribution: nikitas commentedthanx!that was really helpdfull!!!appreciated :)
Comment #17
Daniel Wentsch CreditAttribution: Daniel Wentsch commentedThanks a lot, first patch by Wim Leers worked for me (had to apply the changes manually though).
Comment #18
Brn CreditAttribution: Brn commentedI thought that it was an error of HS but the problem came from NC.
Thank you very much for this patch !
Comment #19
douglasmiller CreditAttribution: douglasmiller commented@pwolanin: I'm still having this issue to date. We will ignore that I am stuck using D6 on the site in question :)
You asked for an explanation of what the underlying problem is. I have been digging around and stepping through with a debugger and I think that I have an explanation for you.
The Hierarchial Select callback function, hierarchical_select_json, requests data from the cache_hierarchical_select cache for the hs_form_build_id on line 328 of HS version 6.x-3.8:
The data portion is an array and the 'file' index is included by HS on line 344:
During the initial clone operation, before a save, the 'file' is reported to be sites/all/modules/node_clone/clone.pages.inc. However, during a normal node editing process, the 'file' index is modules/node/node.pages.inc.
This value is set in the cache in the clone_node_prepopulate call to drupal_get_form. Specifically, it is set in hierarchical_select_after_build in HS.module which starts on line 738. The 'file' index is populated with a value obtained via a menu_get_item call. Naturally, clone.pages.inc is the value since the node/%node/clone path is implemented there.
Wim Leers' solution of adding require_once to the clone.pages.inc works because HS will "incorrectly" load the clone.pages.inc instead of node.pages.inc. Wim Leers' require_once is kind of a hotwire solution, though it works.
I suspect that you are no longer working on the D6 version, but I wanted to explain what was happening and why the patch is necessary!
Comment #20
douglasmiller CreditAttribution: douglasmiller commentedstatus update