0
votes

I have a very strange case in new developpement of an site web. I had made a block (with a custom module) and I make a node_load. Here all is ok, the node is load, the block is display. But for if I change nid of node (by exemple set null) and do nothing else (no node_save, no function call, NOTHING with this object), I have some notice of different module (like 3 or 4 modules). I know it's just notice, but I would understand why the simply fact of change variables wich is never uses, trigger some error..... Exemple :

$tmp = node_load(arg(1));
$tmp->nid=null;

=> error (lot of "Trying to get property of non-object in..." in diffrent name function)

$tmp = node_load(arg(1));
$node=$tmp;
$node->nid=null;

=> error (lot of "Trying to get property of non-object in..." in diffrent name function)

$tmp = node_load(arg(1));
$node = new stdClass();
//Copy via une boucle sinon on a des erreurs.
foreach ($tmp as $key => $value) {
  if ($key != 'nid') $node->{$key} = $value;
}

=> all is ok

1
What is the code that follows the one you shown? Why are you setting the node ID to NULL for a temporary variable?apaderno

1 Answers

0
votes

Ok finally it the comportement of references object php, we must applicate method Clone php on an object to make an copy, or the object will be refeerences