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.

CommentFileSizeAuthor
plus1-nid-is-null.patch729 bytesser_house
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rogical’s picture

Status: Needs review » Needs work

In this way, the plus1 will never show in teaser mode, it's not good.

We need the plus1 also shows well on teaser mode.

rogical’s picture

Version: 7.x-1.0-alpha1 » 7.x-1.x-dev
Status: Needs work » Postponed

Just tested in the node preview, the dev seems working.

ser_house’s picture

Unfortunately (7.x-1.x-dev):

Notice: Trying to get property of non-object в функции plus1_build_node_jquery_widget() (строка 294 ... plus1.module).
Notice: Trying to get property of non-object в функции plus1_build_node_jquery_widget() (строка 296 ... plus1.module).
Notice: Trying to get property of non-object в функции plus1_build_node_jquery_widget() (строка 297 ... plus1.module).
Notice: Trying to get property of non-object в функции plus1_build_node_jquery_widget() (строка 302 ... plus1.module).
Notice: Trying to get property of non-object в функции plus1_build_node_jquery_widget() (строка 308 ... plus1.module).
Notice: Trying to get property of non-object в функции plus1_build_node_jquery_widget() (строка 309 ... plus1.module).
Notice: Trying to get property of non-object в функции plus1_build_node_jquery_widget() (строка 310 ... plus1.module).

rogical’s picture

Status: Postponed » Fixed

Committed, the patch runs quite well.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.