Posted by dagmar on January 17, 2009 at 9:16pm
Jump to:
| Project: | Custom Tokens |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Hello:
I try to use this module with filefield and filefield_paths and I have discovered a small, but important bug.
I create some node custom tokens.
Filefield try to replace the user tokens from the file path. This function
<?php
function token_custom_token_values($type, $object = NULL, $options = array()) {
$result = db_query("SELECT * FROM {token_custom}");
while ($row = db_fetch_object($result)) {
switch ($row->type) {
case 'taxonomy':
case 'node':
case 'comment':
case 'user':
$tokens[$row->id] = _token_eval($row->php, $row->type, $object);
break;
default:
$tokens[$row->id] = _token_eval($row->php, $row->type);
break;
}
}
return $tokens;
}
?>Will execute the php code for the node token, and because the code is expecting a node, it returns an empty value. But an empty value is a valid value for replace a token. Then, the node token is replaced by an empty string and it would not be processed later.
I don't know if this issue is valid for the 5.x version.
Sorry for my english
| Attachment | Size |
|---|---|
| token_custom_d6.patch | 556 bytes |
Comments
#1
Nice catch. I have fixed this in a slightly different way from your patch, but thanks for submitting it.
I should also mention that you have a variable $type available on your PHP code that holds the type of the token).
a.=
#2
Automatically closed -- issue fixed for 2 weeks with no activity.