Closed (duplicate)
Project:
Token
Version:
5.x-1.9
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
29 Jul 2007 at 05:22 UTC
Updated:
5 Jan 2008 at 20:53 UTC
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
Comment #1
gregglesWhat is the problem here? How does this problem manifest itself? How can this be tested?
Thanks.
Comment #2
jbrown commentedthe 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?
Comment #3
greggles@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
Comment #4
gregglesI don't know how this can be critical without a description of the problem that it causes. Could someone clarify?
Comment #5
gregglesactually, 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.