Posted by mkalkbrenner on March 3, 2008 at 3:04pm
| 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.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| node_module_5_7.patch | 1.77 KB | Idle | FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch node_module_5_7.patch. | View details | Re-test |
Comments
#1
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
I adjusted theme_node_preview() and added a comment like requested. And I created the patch against drupal 5.8 now.
#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
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.
#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
The last submitted patch, d6_node_view_php5.patch, failed testing.
#8
node_module_5_7.patch queued for re-testing.
#10
node_module_5_7.patch queued for re-testing.