Closed (fixed)
Project:
Pathauto
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
6 Feb 2009 at 11:45 UTC
Updated:
27 Mar 2010 at 19:50 UTC
Jump to comment: Most recent, Most recent file
I noticed that the implementation of hook_token_values() check if the $type parameter is also equal to 'all', and the switch statement includes a default statement that executes the same code executed when $type is equal to 'taxonomy'.
hook_token_values() should never get such value for $type, and the code executed when $type is not equal to 'node'could receive an $object that doesn't have a tid property (this could happen if token.module defines a new value for $type, or a third party modules defines a new token category).
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 370137-pathauto-token-values-D6-2.patch | 10.6 KB | dave reid |
Comments
Comment #1
gregglesI think it should be possible to get "all" #173699: hook_token_values should handle "all" ?
Is there a specific bug related to this or it just seems bad to you?
Comment #2
avpadernoThere is a module that defines a new group of tokens, and then it calls
token_replace()passing its custom object (and using for$typea value that is not normally used from token.module).I don't remember the name of the module, but I used it for some time in my local site; I uninstalled it more than one month ago.
I guess that using that module pathauto.module would try to access a property that doesn't exist for the custom object used by the module.
Comment #3
dave reidThe problem is this logic:
If I use type = 'user', it's going to trigger the default condition and try to get taxonomy tokens. Luckily there's some built-in checking, but the whole logic of this seems like it could use some cleanup.
Comment #4
dave reidIt would probably be better if pathauto_token_values('node') wants the taxonomy tokens for a node, to call pathauto_token_values('taxonomy') from within itself and merge the tokens together. That's a little easier to understand and follow than the switch/case/fallback code.
Comment #5
dave reidHere's my patch for revamping the implementation of pathauto_token_values(). Also includes tests for the [catpath/catalias] tokens, working on getting tests for the [termpath/termalias] tokens.
Comment #6
dave reidAnd we shoudn't be allowing 'all' in pathauto_token_values(). As per the token module implementations, it has to be specifically 'node' or 'taxonomy', etc.
Comment #7
Anonymous (not verified) commentedThe patch resolves the problem I pointed out, and it also adds more tests for the code.
should not be used as
$typebecause token.module doesn't pass that value tohook_token_values(), nor it will never pass such value (what object should then token.module pass in this case?).Comment #8
dave reidComment #9
dave reidCommitted to both Drupal 6 branches, working on up-porting to the Drupal 7 branch.
http://drupal.org/cvs?commit=341090
http://drupal.org/cvs?commit=341102