Closed (duplicate)
Project:
Drupal core
Version:
7.x-dev
Component:
node system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 May 2009 at 18:21 UTC
Updated:
4 May 2009 at 19:24 UTC
Apologies if this a 'by design' known or/and wanted result. But here we go..
I've tracked this to when node_load_multiple() was introduced in #324313: Load multiple nodes and terms at once. Before, the node was being cloned before it's returned from the cache. Now it is not. This probably has the benefit of consuming less memory, but also some other nasty side effects. For example, check this code:
// Place in your drupal root, this is a file for reproducing static caching/cloning bug.
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// The node nid to test with, change it to any node nid you may have in the database
$nid = 1;
$node = node_load($nid);
drupal_render(node_build($node)); // > /dev/null
unset($node)
$node = node_load($nid);
// Expected: False, Result: True
var_dump(isset($node->content));
// Expected: Lots of HTML, Result: NULL.
var_dump(drupal_render(node_build($node)));
Comments
Comment #1
damien tournoud commentedThe main issue is probably that node_build() is not reentrant. It should.
Comment #2
AmrMostafa commentedBut why is node_build() the main issue? :)
I was using it only as an example, here is another one:
Comment #3
damien tournoud commentedIt's the caller responsability to clone the object if it needs to be modified, see #154859: Document that cached entity objects are not necessarily cloned any more.
But definitely, node_build() not being reentrant is a bad thing we should fix.