Hi,
this is not really a bug in ds, but many miraculous ds/nd bugs might actually be caused by this.
Thus, I want to let you (maintainers of ds) know about it.
#1458806: content_token_values() switches build mode to token (and doesn't switch it back)
Feel free to close as duplicate, leaving this as a search beacon.
I set this as a "support request", to not add to the count of open bugs :)

content_token_values() does change the build mode of the object that it receives as an argument to be "token".
If that node is cached (which is usually the case), and after the procedure it is rendered, the build mode will still be on "token", instead of what it used to be (such as, "full" or "teaser" or whatever).

In general, this is a design flaw in Drupal core: The same cached node object is used for a variety of procedures, which all have free write access on the node's properties. This is a wide-open door for nasty side effects.

Real fix:
Clone the node object, before it is passed into hook_token_values(). This might have other consequences, why it would be better to postpone into a major version upgrade of token.

In the end, this "real fix" was the only thing that saved me.

I hope this information is useful.

Comments

xtfer’s picture

Title: token causes ds to use settings from wrong build mode » Attempt to cache build mode before other modules can change it (token causes ds to use settings from wrong build mode)
Assigned: Unassigned » xtfer
Category: support » task

Good catch.

DS (in 6.x at least) has a number of places where it relies on something being set on the node already, build mode being just one. CCK field settings are another notoriously fickle, similar can of worms.

It might be possible for us to catch the build mode earlier, however, and cache it for later use. I'm not sure if its possible, but worth investigation. I've changed this to a task.

donquixote’s picture

Ok.
I just want to mention, that the build mode might not be enough.
On the site where this happened, I saw two effects:

1) After an upgrade to a few modules, incl token:
-> Nothing shown for the node at all in full view, because it was rendered as "token" build mode. I think I saw this in the html source.

2) After I modified content_token_values() to remember the build mode and restore it afterwards:
-> Field labels for all text fields gone, or not the way they were configured in build mode "full".

I think this should be fixed in whatever module touches the node first, using clone.
But, if you want to do something in ds directly, go ahead :)

aspilicious’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Closing all the drupal 6 issues as support for that version has been dropped.