If you run php5 you can't call node_view() twice for the same node because $node is treated as a reference if it's passed as an object.

The current implementation of node_view() explicitly tries to clone the node object the php4 way by not using the reference operator '&'. So if you use php5 node_view() manipulates the original node object.

I attached a patch that solves the issue using drupal's own clone functionality.

Comments

drumm’s picture

Status: Needs review » Needs work

A brief code comment should be added to explain why this is being done.
theme_node_preview() does cloning before passing to node_view(), this can be removed.

This bug appears to be present in Drupal 6, but not Drupal 7.

mkalkbrenner’s picture

Version: 5.7 » 5.8
Status: Needs work » Needs review
StatusFileSize
new2.63 KB

I adjusted theme_node_preview() and added a comment like requested. And I created the patch against drupal 5.8 now.

bambangfals’s picture

@mkalkbrenner
thanks for your patch, are u have apllied to your web?

bambangfals’s picture

i have problem, $node->teaser= $content returned not empty but $node->body = $content returned empty value
this patch not work to be solutions, please help me to resolve this problem.

thanks

mkalkbrenner’s picture

Version: 5.8 » 6.12
StatusFileSize
new3.11 KB

drumm is right. The bug still exists in drupal 6 but drupal 7 handles node_view differently.

So here's the patch ported from drupal 5 to 6.

doublejosh’s picture

Had the same issue. Second use of node_view on the page had empty content.

Sucks to have to patch core. Suppose I could node_load at each spot I want to do the node_view, but that seems wasteful of my processor. (PS: tested, that does work.)

Going ahead with the patch for future resource savings. (PS: tested, works for me too.)

Thanks.

Status: Needs review » Needs work

The last submitted patch, d6_node_view_php5.patch, failed testing.

xjkwak’s picture

Status: Needs work » Needs review

node_module_5_7.patch queued for re-testing.

ericpai’s picture

node_module_5_7.patch queued for re-testing.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.