Download & Extend

node_view() incompatible to php5

Project:Drupal core
Version:6.12
Component:node system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

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.

AttachmentSizeStatusTest resultOperations
node_module_5_7.patch1.77 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch node_module_5_7.patch.View details | Re-test

Comments

#1

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.

#2

Version:5.7» 5.8
Status:needs work» needs review

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

AttachmentSizeStatusTest resultOperations
node_module_5.8.patch2.63 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch node_module_5.8.patch.View details | Re-test

#3

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

#4

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

#5

Version:5.8» 6.12

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.

AttachmentSizeStatusTest resultOperations
d6_node_view_php5.patch3.11 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch d6_node_view_php5.patch.View details | Re-test

#6

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.

#7

Status:needs review» needs work

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

#8

Status:needs work» needs review

node_module_5_7.patch queued for re-testing.

#10

node_module_5_7.patch queued for re-testing.

nobody click here