We need a note in the API.txt that reminds people that $objects are different during the addition vs. editing vs. bulk updates and that their hook_token_values should be strong enough to figure out the "right thing".
I propose something like:
When an object is created (whether it is a node or a user or a taxonomy term) the data that Pathauto hands to the token_values in the $object is in a specific format. This is the format that most people write code to handle. However, during edits and bulk updates the data may be in a totally different format. So, if you are writing a hook_token_values implementation to add special tokens, be sure to test creation, edit, and bulk update cases to make sure your code will handle it.
Thoughts?
Comments
Comment #1
jcfiala commentedSounds good to me - I didn't realize I'd have to write for two formats when I was doing my plugin, and I'm glad Greg was able to warn me before my code went live.
Comment #2
Freso commented"Be liberal in what you accept, and strict in what you produce."
Text sounds fine to me. But then, I don't really have much of a preference in this regard, so... :) (Also, it should probably be backported to 6.x-1.x (and possibly 5.x-2.x?) when/if the API.txt change goes in.)
Oh, and the status is misleading... there is no patch right now. ;)
Comment #3
gregglesYou caught me mislabeling this ;) But for a docs issue it seems worth deciding on the change first and then making the patch.
And I agree - this is worth fixing for 6.x-2, 6.x-1, 5.x-2.
Comment #4
gregglesI'm marking this as a duplicate of the newly repurposed #309820: Update API.txt for other modules.
And yes, this should hit all 3 branches. Thanks for the reminder, Freso.
Comment #5
gregglesahem