Ok, after a morning of debugging as to why this problem is happening, and some help from a few people in #drupal I found the problem to stem from token_cck.inc.

In short, this line:
$node = $object

Should be:
$node = drupal_clone($object);

This stops content_view($node) from loading the full node into the actual node you are trying to work with.

Comments

greggles’s picture

What is the problem here? How does this problem manifest itself? How can this be tested?

Thanks.

jbrown’s picture

Title: CCK teaser fields are not respected, it always defaults to the CCK full node view fir fields » CCK teaser fields are not respected, it always defaults to the CCK full node view for fields
Version: 5.x-1.7 » 5.x-1.9
Priority: Normal » Critical
Status: Active » Needs review

the problem is that token_replace() is given the $node to use to replace the tokens, but under php 5 objects are always passed by reference. content_token_values() is calling content_view() which is rerendering the node as full.

drupal_clone() should maybe be in token_replace() for broader protection from rouge modules.

Maybe we should stop using objects like arrays in D7?

greggles’s picture

Status: Needs review » Active

@jbrown - you describe what the code does. I know what the code does (and sidenote: this is not a patch).

How can I test this patch? I need steps like:

1. Install token, moduleX and moduleY
2. Create a cck content type with field X
3. Create a node of that content type

Expected results:
Happiness

Actual results:
Something bad

greggles’s picture

Priority: Critical » Normal

I don't know how this can be critical without a description of the problem that it causes. Could someone clarify?

greggles’s picture

Status: Active » Closed (duplicate)

actually, I just found http://drupal.org/node/149222 which is for the same thing and slightly older and has a patch (though not using drupal_clone). So, I guess we should fix it based on that patch.