When I upgraded from 1.2 to 1.3, I noticed my field tokens like [node:field-redirect-link:url] now output the url without the query string parameters.

I tracked down the problem commit to http://cgit.drupalcode.org/link/commit/?id=85ab462a946b60aa90011b5c4f81e....

Before the commit everything worked fine, after the commit the token changed.

Possible related issues: #2361283: Link 7.x-1.3 removes Query string when using "Image Link Formatter" module

Comments

karenann’s picture

I posted some thoughts on this issue to #2361283: Upgrading to new version 7.x-1.3 removes Query string before I found this ticket.

jcfiala’s picture

Status: Active » Postponed (maintainer needs more info)

Hey, @gmclelland:

I'm trying to reproduce your error in an automated test, and I'm having trouble getting a token named [node:field-name:url] to work. When I look at the list of tokens that I'm using, I'm seeing [node:field_url] instead of, say, [node:field-url] like you're describing. What field token type module are you using that uses dashes for the field name in the token?

I need more information to fix this problem, basically. :)

gmclelland’s picture

Status: Postponed (maintainer needs more info) » Active

It might be provided by the Entity Token module contained in the https://www.drupal.org/project/entity module or the token module. I can't remember which ones provides that format.

I see two tokens
Redirect Link [node:field-redirect-link:?] Field "field_redirect_link". The following properties may be appended to the token: url (The URL of the link.), attributes (The attributes of the link.)

Redirect Link [node:field_redirect_link] Link field.

jcfiala’s picture

Yes, thank you. I guessed that it was the entity_token field and set up a test using that, and now I'm properly getting a url (without querystring) to be replaced.

jcfiala’s picture

Status: Active » Postponed (maintainer needs more info)

I just can't reproduce your problem. I'm using entity module version 1.5, I've got the latest version of link (which does contain the commit you're highlighting) and everything's just working. I just created a test installation of drupal with the latest versions of token, entity_token and link modules, downloaded via Drush.

1) I created a new content type called "Basic Link"
2) I created a new field (also called "Basic Link") which has the field machine name of field_basic_link. I enabled the option "Allow user-entered tokens" on the field so that I could use the title of the field to test tokens.
3) I created a new node of type Basic Link. For the url of the link field, I used "http://www.example.com/lorem?query=string". For the title of the link, I used "*[node:field-basic-link:url]*". (The asterisks are there to confirm that I am seeing the result of processing the title, and not just seeing the url being printed.)
4) And it just works. When I view the node, I'm seeing *http://www.example.com/lorem?query=string*.

And the automated tests work just fine, and they don't even require using the link field to test the tokens - I'm directly calling token_replace($token_name, array('node' => $node)); in the tests, and they're turning a string containing the token into a string containing the url, including the querystring.

So, unless you can come up with a similarly basic example of the token not working... ?

gmclelland’s picture

Hrm... I'm sort of seeing the same thing as you. Here is my findings:

The title is being replaced by the token correctly in the title of the link field.

The token in the node title is correctly being replaced with https://www.drupal.org/project/auto_entitylabel.

The token in a text area using https://www.drupal.org/project/token_filter has the query string removed.

I'm using the http://drupal.org/project/rabbit_hole module to redirect nodes to what is entered in the link field. The page redirects to the link without the query string.

I'm not sure if it is relevant, but I also noticed something strange when viewing the link field with the "Separate title and URL" formatter, the link doesn't display the query string of the link when it is printed to the page. Is that intended?

I've reproduced the problem on another site as well.

jcfiala’s picture

Status: Postponed (maintainer needs more info) » Active

Hmmm.

Okay, I think I see some of what's happening here, based on putting a dpm inside of token_filter. Basically, the node object that is being grabbed by token_filter is slightly 'used', which means that during the rendering process some of the data's getting shuffled about. And after the shuffling, it's broken.

I'm going to have to think about this one.

  • jcfiala committed 2e82084 on 7.x-1.x
    Issue #2367069 by jcfiala:Fixed entity_token for link after node_view...
jcfiala’s picture

Status: Active » Fixed

Okay.

So, the problem is that although the $node after node_load() would work fine with tokens, the $node after node_view() was called wouldn't.

So, now I've got tests in the link.entity_token.test file that makes sure that entity_token values still work after node_view(), and I've got the code in that fixes this problem as well. Once this fix gets included in link 7.x-1.x-dev (sometime tomorrow, I expect) could you please download this dev version and check if it solves these problems for you?

Thanks a lot for answering all these questions. Without it I'm sure I wouldn't have figured out the problem.

gmclelland’s picture

@jcfiala - Yay, that worked! Thank you for sticking with this and tracking it down.

jcfiala’s picture

Not a problem! I'm glad we both tracked this down and put tests in place to guard against this regressing again.

karenann’s picture

@jcfiala - Same here, yay, that worked in my installation as well. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

achton’s picture

This issue hit us hard on a site which makes heave use of Link module. Upgrading to 1.3 broke a lot of things (we should have tested better).

@jcfiala: Any chance of a 1.4 release soon, since this was fixed in dev many months ago now?

altrugon’s picture

Status: Closed (fixed) » Reviewed & tested by the community

I ran into this issue too, updated the module to 7.x-1.x-dev 2014-Nov-06, and after the update I was able to see the query fragment on the URLs again.

Please release the 1.4 version with this fix in it.

Thank you.

rob c’s picture

Status: Reviewed & tested by the community » Closed (fixed)

jcfiala committed 2e82084 on 7.x-1.x
Issue #2367069 by jcfiala:Fixed entity_token for link after node_view...

Please do not reopen aready committed issues.
Open up a followup issue if you run into new issues due to this patch. Thank you.

karenann’s picture

@jcfiala: Thanks for fixing my borked patch on 2361283 and committing it for inclusion in 7.x-1.4! Much appreciated!

sebastien m.’s picture

I'm waiting for 7.x-1.4 to support this patch : https://www.drupal.org/files/issues/link_7.x-1.3-removes-query-string_23...
Help appreciated.
Many thanks !

brunodbo’s picture

This fixes the issues with query strings, but I noticed some breakage when using hook_preprocess_link(). Not sure whether this is Link's responsibility though. See https://www.drupal.org/node/2549701.