Notice: Undefined property: stdClass::$nid in _sps_preprocess() (line 419 of /sites/all/modules/sps/sps.module).

As an example, looking at sps.module, line 419 we are iterating over $vars['view']->result

The code assumes that the result will contain an NID. However, these rows that are looped over may not always have $row->nid -- the data structure provided by fields that are brought in via references is quite different.

Not exactly sure what the best way to deal with this is, but in order to prevent errors I'm currently wrapping the loop in an isset() function.

416     case 'views_view_list':
417       if($vars['view']->base_table == 'node') {
418         foreach($vars['view']->result as $index => $row) {
419           if (isset($row->nid)) {
420             if ($class = $manager->react('add_class', array('id'=> $row->nid, 'type' => 'node'))) {
421               $vars['classes_array'][$index] .= " $class";
422             }
423           }
424         }
425       }
426     break;
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

saltednut’s picture

Issue summary: View changes

Updated issue summary.

dsim’s picture

This warning might be due to non-existance of node object.

So to avoid that, we need to check the nid exists before using it.

Thanks

alberto56’s picture

Status: Active » Reviewed & tested by the community

This works for me.