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
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.

AttachmentSize
facebook_status_module_collision.patch1.36 KB

#1

IceCreamYou - September 24, 2009 - 23:58
Status:needs review» postponed (maintainer needs more info)

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

rfay - September 25, 2009 - 02:17
Status:postponed (maintainer needs more info)» needs review

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

IceCreamYou - September 25, 2009 - 02:53

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

rfay - September 25, 2009 - 02:59

Yes, removing the token 'operation' from facebook_status would do the job for my problem. Thanks.

#5

IceCreamYou - September 25, 2009 - 03:12
Status:needs review» fixed

Committed to CVS

#6

rfay - September 25, 2009 - 03:16

You can't get a more responsive maintainer than that! Thanks so much!

-Randy

#7

System Message - October 9, 2009 - 03:20
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.