Steps to reproduce;
- Install a version of Link module
7.x-1.x-devrecent enough to include this patch from comment 14 at #1321482. I actually used7.x-1.0with that patch applied. - Configure the site such that certain types of node updates occur twice in one request. I have not narrowed down exactly which types of node-updates. For the purpose of this issue and patch I don't think it matters. This configuration reproduced the bug for me;
- Install Workbench Moderation and Rules modules.
- Create a Rule that is triggered by moderation transition;
- Add a condition, such as that the "Sticky" flag must be set. This will make testing easier.
- The Rule's actions should automatically publish content. That means it sets the moderation state to
published.
- Configure a content type with a Link-module link-field.
- Create content with URLs that include fragments and/or query string parameters.
- Transition the content's moderation state such that the Rule does not trigger, so that only one moderation transition occurs in the request that is handled by form submission.
- Note that the URL in the rendered link field is the URL that was entered into the node edit form. Awesome!
- Now set the content's state such that the Rule does trigger, so that two moderation transitions occur in the request that is handled by form submission.
- Expected behaviour: The URL in the rendered link field matches what was previously entered into the node form.
- Actual behaviour: The fragment appears twice in the URL. I am not sure why this does only happens to fragments and not query strings.
- Create a new draft from the published content. AKA, edit the node.
- Expected behaviour: The URL in the link field of the node form matches what was previously entered into the node form.
- Actual behaviour: The fragment and query are duplicated in the URL in the link field of the node form.
This patch fixes the issue by unsetting $item['fragment'] and $item['query'] in _link_process() so that subsequent calls to the link_field_presave() (_link_process()'s only caller) in the same request don't append the fragment or query to the URL again.
I am not sure if this breaks other things.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | duplicate-fragment-query-1646360-1.patch | 697 bytes | zach harkey |
| #1 | 1646360-link_with_wb_moderation.patch | 533 bytes | Bevan |
| link_with_wb_moderation.patch | 533 bytes | Bevan |
Comments
Comment #1
Bevan commentedThis patch is identical but has no offset against
7.x-1.x-dev.Comment #2
zach harkey commentedYour code works but it assumes the existence of another patch from #1321482: Query string and fragment are removed and it looks like that issue was closed without ever committing the necessary lines.
Here is a new patch that should apply cleanly to 7.x-1.x
Comment #3
rreiss commentedI had the same issue on Link 7.x-1.0.
Links with query params. was printed twice, I guess that once because of the query saved with the URL and second because of the query params. sanitation performed on function `_link_sanitize`.
The patch here didn't work for me, due to different structure of the involved arrays, but the link from https://www.drupal.org/node/1984398#comment-7365328 did work.
Thanks.
Comment #4
jcfiala commentedIs anyone still having this problem with Link 7.x-1.3?
Is there a way to reproduce this which is less complex?
Comment #5
jcfiala commentedI repeat myself, as I'm changing the status:
Is anyone still having this problem with Link 7.x-1.3?
Is there a way to reproduce this which is less complex?