Closed (fixed)
Project:
Plus 1
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
8 Oct 2012 at 17:50 UTC
Updated:
6 Feb 2013 at 05:20 UTC
When I trying to see the new node in preview mode, the notice appear:
Notice: Trying to get property of non-object in plus1_build_node_jquery_widget() (line 282 of plus1.module)
It is because $node->nid is NULL in preview mode, but the function plus1_node_view did not consider this case.
This patch adds a checking value of $node->nid.
function plus1_node_view($node, $view_mode) {
// Only show the voting widget in allowed content types.
- if (in_array($node->type, variable_get('plus1_node_types', array()))) {
+ if ($node->nid && in_array($node->type, variable_get('plus1_node_types', array()))) {
if (($view_mode == 'teaser' && variable_get('plus1_node_in_teaser', 0)) || ($view_mode == 'full' && variable_get('plus1_node_in_full_view', 1))) {
$node->content['plus1_widget'] = plus1_build_node_jquery_widget($node->nid);
}
PS: sorry for my writing mistakes.
| Comment | File | Size | Author |
|---|---|---|---|
| plus1-nid-is-null.patch | 729 bytes | ser_house |
Comments
Comment #1
rogical commentedIn this way, the plus1 will never show in teaser mode, it's not good.
We need the plus1 also shows well on teaser mode.
Comment #2
rogical commentedJust tested in the node preview, the dev seems working.
Comment #3
ser_house commentedUnfortunately (7.x-1.x-dev):
Comment #4
rogical commentedCommitted, the patch runs quite well.