Token name collision with activity module (token: 'operation')
rfay - September 24, 2009 - 20:26
| Project: | Facebook-style Statuses (Microblog) |
| Version: | 6.x-2.0-rc2 |
| Component: | Code - API |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Both facebook_status and activity module define the token 'operation'.
Unfortunately, due to the way Drupal and token handle this, the value for [operation] end up being an array, which breaks all the code that deals with it, resulting in output (for any module) like 'Joe Arrayd a picture'.
The attached patch differentiates the name of 'operation' for this token. I know this could have been done either place. But doing it here means that facebook_status should never have to deal with this again.
| Attachment | Size |
|---|---|
| facebook_status_module_collision.patch | 1.36 KB |

#1
There should never be any collision because the token module prepends the module name to the front of the token, i.e. [facebook_status:operation] and [activity:operation]. The only place this doesn't happen that I'm aware of is on the Activity Publisher Templates in Activity 2.x where Activity takes care of the differences itself, so there's no conflict there either.
I haven't used Activity 1 in a long time, so I take it you're using that branch?
Note that I'm hesitant to change tokens unless absolutely necessary because it will break things for people who already have their system set up and working. Also, you should never actually need to use the token [operation] with FBSS because it is never anything other than "update."
#2
Thanks for the quick response, @IceCreamYou,
This is Activity 6.x-1.2, facebook_status 6.x-2.0-rc2, and Token 6.x-1.12.
I stepped through the code, and I cannot confirm what you say about Token prepending the module name. The use of array_merge_recursive just pulls them all right in on top of them. So if you have both activity and facebook_status installed, which both define the 'operation' token, you'll get the value of 'operation' being an array, and unusable. And it makes me sad, of course, because this is a natural collision. I did file #587148: Handle tokens correctly when more than one module defines a given token against token about this issue.
#3
Ah, yeah, actually I was wrong about that -- I was thinking about something else. Maybe I should just get rid of the operation token then, since it's not actually used for anything. What do you think?
#4
Yes, removing the token 'operation' from facebook_status would do the job for my problem. Thanks.
#5
Committed to CVS
#6
You can't get a more responsive maintainer than that! Thanks so much!
-Randy
#7
Automatically closed -- issue fixed for 2 weeks with no activity.