Closed (fixed)
Project:
Token
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
24 Sep 2009 at 20:31 UTC
Updated:
20 Dec 2010 at 00:13 UTC
Jump to comment: Most recent file
Currently, if more than one module defines a token with a given name, the token value becomes an array, because array_merge_recursive is used to build the result array. This completely confuses all the user modules, making the token useless.
I propose:
1. Documentation on how to declare tokens. Do they have to namespace their tokens?
2. Choosing the first token of the array and providing it in this case. Perhaps module weights could be used in the battle then, but at least there would be a way to resolve this.
Right now, the only resolution is to patch one of the modules to namespace the token. I just had to do this in #587140: Token name collision with activity module (token: 'operation')
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 587148-token-check-duplicate-tokens.patch | 2.04 KB | dave reid |
| #4 | 587148-token-check-duplicate-tokens-D6.patch | 2.04 KB | dave reid |
| #2 | token_module_array_resolution_587148_01.patch | 856 bytes | rfay |
Comments
Comment #1
rfayPer conversation on IRC with @greggles:
I'll try to create a patch which:
1. Chooses the last token value (highest-weighted module's version) instead of returning the array.
2. Emits an error message to watchdog (perhaps to DSM)?
The error message to watchdog will need to be throttled somehow or it will fill the log.
Comment #2
rfayThe attached patch does as described in #1.
I'm certainly open to a simpler approach, but didn't find one. I am convinced that token_get_values() is the correct place to be doing this checking. A more extensive change to the actual processing of tokens would be another way to deal with this problem.
I chose not to emit a drupal_set_message() as it is enormously intrusive and punishes the integrator or user for something they may not be able to fix.
Comment #3
rfayComment #4
dave reidHere's a modified version that extracts this logic into its own function. We need this is now that we're adding more tokens like node-url and node-path.
Comment #5
dave reidRe-uploading for the bot to test.
Comment #6
dave reidCommitted to CVS!
http://drupal.org/cvs?commit=388034
Comment #7
rfayWow, I never thought that would see the light of day :-)
Comment #8
dave reidYeah sorry it took so long. This got bumped in priority once we added the [node-url] tokens which seem to be defined in lots of other modules.
Comment #10
mariagwyn commentedOn what version is this fixed? And what does the "fix" look like? I use notifications, still get the error message in the log, though functionality does not seem to be impaired. I also commented on the notifications issue hoping to get it addressed.
Comment #11
dave reidAll versions it was fixed. Instead of blowing up and completely breaking your site, token.module now alterts you when more than one module defines a token. Most times it will have to be fixed in the offending module since no other module should define the same tokens as token.module. So, in this case this needs to be fixed in the notification module.
Comment #13
allan1015 commentedIf this is the wrong place to post this please let me know
I understand these issues may be from other modules, but I read somewhere in Toekn issues that you all were attempting some general fix and someone said to let you know of any Duplicate Token issues
Using Token 6.x-1.x-dev (2010-Dec-14)
The Notification Module, 6.4-beta7 still has this issue - a patch seems to not be fully applied
http://drupal.org/node/845250
The CCK Signup Notifications (enabled in Notifications part fo Modules but I think its CCk Signups issue)
http://drupal.org/node/1002784