I use both moduls, automatic nodetitles and this relativity modul. the problem is, that if i create a node with automatic nodetitles there will be a sql bug. Even if the nodetype does not use relativity. Is there any solution for this problem?

Comments

darius’s picture

Status: Active » Closed (won't fix)

The description is not adequate. Maybe it's a Automatic Nodetitles issue?

thekk’s picture

Title: Automatic Nodetitles Problem » Token Module Problem
Version: 5.x-2.1 » master
Status: Closed (won't fix) » Needs review
StatusFileSize
new8.31 KB
new658 bytes

No, this is not a Automatic Nodetitles issue. This has to do with the fact that Automatic Nodetitles uses the token module to set the titles.
How to duplicate?
Install Node Relativity, Token and Automatic Nodetitles
Create a parent content type & node.
Create a child content type, set Automatic Nodetitles to autogenerate a title using the token module.
Create child node from parent and preview. This generates an error coming from node_load(), around line 521.

Upon debugging using:

$backtrace = debug_backtrace();
echo $backtrace[1]['function'];

in node.module, I found out that the calling function was 'relativity_token_values'... That function tries to create a full node using the 'nid' of a node, but because the function is called when the nid is not yet set, this gives an error in node_load().

I propose to remove the call to node_load, because it is expensive: it fires the load event of nodeapi. This effectively loads the node twice from the database, only to gather the parent_nid. In my case this was already available (and I haven't seen this construction anywhere else). This is fixed in the node_load patch.

Also: I found that the variable name for returning the token values is not consistent: declared as 'tokens', returned as 'values'. This is fixed in the tokens-var patch.

darius’s picture

Version: master » 5.x-2.x-dev
Priority: Normal » Critical

Hi,

could someone confirm that the proposed patch above (relativity node_load.patch) fixes the SQL problem and does not cause any other? In particular,

a) Omar: do you remember the reason for:

// load the node just to avoid problems with module weights
$node = node_load($object->nid);

rather than simply

$node = $object;

b) rsmith5: could you verify the patch fixes your problem?

For the reference, here is the original issue introducing token support: http://drupal.org/node/151731

As soon as we get some confirmation, I'll commit the patch.

owahab’s picture

Assigned: kev52 » owahab
Status: Needs review » Reviewed & tested by the community

I reviewed the patch and see it as RTBC.

Unless someone state otherwise, I'll commit this next week.

jody lynn’s picture

Hey we needed this patch too to fix the bug. Please commit! Thanks

darius’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 5.x-2.x-dev branch.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.