I installed Hierarchical Select (+Hierarchical Select nodereference) on an OpenAtrium distribution. During creation of new nodes, HS forms worked fine, but while editing a node I get 'Received an Invalid Response from the Server' error. In OpenAtrium, the URL for editing a post within a group 'mygroup' is not mysite.com/node/34/edit, but instead mysite.com/mygroup/node/34/edit. PURL is handling the prefixing (among other things). The prefix 'mygroup' was lacking in the URL contained in the JS setting HierarchicalSelect->basePath. Lack of this group prefix caused the error (PURL redirected to the corrected URL and the request data was lost).
I managed to get HS working by hacking _hierarchical_select_setup_js function in the hierarchical_select.module file to correct the JS property "settings->HierarchicalSelect->basePath". In my case it was enough to pass the $url through purl_url_rewrite function + correct the resulting double slashes.
if (module_exists('purl')) { // this works for clean URLs only
$dummyarr = array();
purl_url_rewrite($url, $dummyarr, $url);
$url = str_replace('//', '/', '/' . $url);
}
I hope this duct-tape hack saves someone some time and maybe Wim will be able to come up with a better solution for future releases.
Comment | File | Size | Author |
---|---|---|---|
#15 | hs_736792.patch | 2.51 KB | vectoroc |
#10 | hs_purl.patch | 724 bytes | paolomainardi |
#8 | hs_purl.patch | 874 bytes | paolomainardi |
#6 | hierarchical_select_purl_basepath.patch | 1.47 KB | alexku |
#2 | hierarchical_select.736792.patch | 1006 bytes | randallknutson |
Comments
Comment #1
Wim LeersPlease roll a proper patch.
I'm not going to test this patch, it requires too much time. I won't commit it until at least one other person has confirmed that the patch works and has no side effects.
Comment #2
randallknutson CreditAttribution: randallknutson commentedWe ran into this exact same problem using purl and hierarchical select. I tried out his ideas and it worked for us. Here is the patch of our modifications.
Comment #3
rbenhase CreditAttribution: rbenhase commentedHi,
I'm running Open Atrium with HS + HS Nodereference as well, and I had the exact problem you described. However, neither your tadeusz.zimirsk's hack nor randallknutson's patch has solved the problem for me.
I did notice one thing, however; before the patch, in addition to the "Received an Invalid Response from the Server" error, I would get three error messages printed after a refresh or navigating to another page:
After patching, these error messages do not appear--I just get the "Received an Invalid Response from the Server" error. So, it appears the patches did SOMETHING, but perhaps my problem is elsewhere. I've come across threads regarding HS and compatibility with Ctools and Content Profile, but those issues appear to have been resolved. Is there anything else that this could be?
Comment #4
Wim LeersI'm going to tentatively commit randallknutson's patch: http://drupal.org/cvs?commit=412124
If people still have problems with this, please reopen this issue!
Comment #6
alexku CreditAttribution: alexku commentedI have a problem with current solution and a setup with $base_path other than /
The problem is that if you have something like '/subfolder' in $base_path purl_url_outbound_alter() thinks that it is part of the query and in the result you get url like '/og_group_name/subfolder'.
So I think the logic should be:
1. add clean_url part if it is necessary (at this point we might have 'index.php?q=')
2. add language prefix if it is necessary (at this point we might have 'index.php?q=lt/')
3. ask purl_url_outbound_alter if it wants to add something (it might give us 'og_group_name/' for example)
4. get $base_path (it might be something like '/subfolder/')
5. combine three parts and get for example: /subfolder/index.php?q=lt/og_group_name/
I have attached a patch which works for me with openatrium in a subfolder multisite install. I have also tested it with clean urls off and with language prefix on.
Comment #7
Wim LeersComment #8
paolomainardi CreditAttribution: paolomainardi commentedSame problem here, i've just found another solution, removing base_path() from $url before to get it processed by purl and re-added just after, in order to preserve language, cleanurl, etc.
Patch in the attachment.
Comment #9
Wim LeersIf alexku could confirm that your patch is working, I could commit it. I'd need a proper patch though, this patch can't be applied with the patch command. And you'd need to make some changes to comply with the Drupal coding standards.
Comment #10
paolomainardi CreditAttribution: paolomainardi commentedIn the attachment the corrected patch in order to be applied with usual patch command, sorry it was previously created within my git repository.
I've just fixed the space on string concatenation as requested by Drupal coding standard, i think it will be enough.
Comment #11
Wim LeersThanks for the re-roll! :) Now all we need is confirmation from alexku!
Comment #12
alexku CreditAttribution: alexku commentedI can confirm that it does work, but I wouldn't rely on str_replace
Maybe it would be safer to check if string begins with base_path?
Comment #13
Wim LeersAgreed, let's fix that.
Comment #14
alexku CreditAttribution: alexku commentedSorry, I didn't test the language prefix properly.
Patch by paolomainardi doesn't work with language prefix, because purl still gets it and thinks that it is part of the query.
I'm staying with my patch in #6 because it has been on a live site for almost two month without any issue
Comment #15
vectoroc CreditAttribution: vectoroc commentedI dont understand why you used these hacks?
There is my patch (works with purl+spaces / lang prefix).
Comment #16
vectoroc CreditAttribution: vectoroc commented@Wim Leers: what do you think about my patch? is it sufficient?
Comment #17
btopro CreditAttribution: btopro commentedCan confirm that this patch works in PURL / OG / Spaces based environments like open atrium.
Comment #18
alippai CreditAttribution: alippai commentedWorks with OpenAtrium.