The following script prints a wrong result:

$node=new stdClass();
$node->title='My Node';
node_save($node);
var_dump($node->nid);
var_dump($node->vid);

$node=node_load($node->nid);
var_dump($node->nid);
var_dump($node->vid);

$node->revision=true;
node_save($node);
var_dump($node->nid);
var_dump($node->vid);

$nid=$node->nid;
$node=node_load($nid);
var_dump($node->nid);
var_dump($node->vid);

exit();

-----------------------------------

example output:

string(2) "86"
string(3) "163"
string(2) "86"
string(3) "163"
string(2) "86"
string(3) "164"
string(2) "86"
string(3) "163"

expected output (in this example):

string(2) "86"
string(3) "163"
string(2) "86"
string(3) "163"
string(2) "86"
string(3) "164"
string(2) "86"
string(3) "164"

An xdebug-trace of the final node_load() reveals what the problem is:

node_load() simply takes the cache from the previous node_load(), not considering that this cache has become stale by us calling node_save(). This happens in node.module in lines 707-710.

Database content is not directly affected by this bug: Data sets in the database correctly reflect the new revision (164).
However user scripts may cause inconsistencies in the database by relying on wrong information returned by node_load().

Comments

BauerDigitalKG’s picture

Version: 6.14 » 6.16

We've reviewed the bug again: It is also present in version 6.16.

dtrdewaele’s picture

Is this bug fixed in Drupal 6.17? I have a simular problem with cck data that is not coming correctly from cache.

damien tournoud’s picture