Posted by savedario on September 5, 2011 at 10:55am
1 follower
Jump to:
| Project: | FriendList |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
Hi there,
I have installed:
- Friendlist 6.x-1.x-dev
- Token 6.x-1.x-dev
- Rules 6.x-1.x-dev
When a new friendship request is made, the emails that get sent out to the requester and the requestee are correct, but some of the token/s contained in them (e.g. [rtid:name] do not get replaced with the proper value whereas others (e.g. [user1:site-url]) are substituted correctly.
I checked in admin/help/token and the friendlist tokens are not listed.
Has anyone encountered this problem ?
Comments
#1
Some more information:
I did a bit of debugging while the rules execute (ouch) and noticed that when rules_get_variables() is called with $names = array('user1'=>'user1','rtid'=>'rtid'), the returned variable $args = array('user1'=> {object of StdClass} , rtid => 1) shows the correct content from $state which obviously has the wrong data in it.
#2
Changing to bug report to get attention.
Apparently it's only the token [rtid:name] that does not get replaced.
#3
More debugging...
It seems the hook friendlist_rules_token_values() is never called when the time comes to get the value to replace the token.
#4
My findings:
Since the file friendlist_rules.rules.inc is included by the rule module, drupal is not informed that the same file contains an implementation of hook_token_values so, when it comes to call all the hooks, the friendlist_rules module is never checked.
Workaround #1
Implement a copy of friendlist_rules_token_values() in a custom module.
Workaround #2 (not tested)
Add a call to module_implements() and force rebuilding of the hook implementation list.
Workaround #3
Move the hook friendlist_rules_token_values() elsewhere so that drupal can find it.
I am not sure I will have the time to explore a better solution other than workaround #1.
I would appreciated some feedback...
#5
#6
Once again:
It turns out workaround #3 is easier than I thought and actually quite logical.
By moving:
- friendlist_rules_token_list()
- friendlist_rules_token_values()
from friendlist_rules.rules.inc to friendlist_rule.module, the tokens are properly replaced.
I am no good at making patches, but I will give it a try...
TBC