Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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;
Comment | File | Size | Author |
---|---|---|---|
#1 | warning_nid_preprocess-2091509-2.patch | 1.62 KB | dsim |
Comments
Comment #0.0
saltednutUpdated issue summary.
Comment #1
dsim CreditAttribution: dsim commentedThis 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
Comment #2
alberto56 CreditAttribution: alberto56 commentedThis works for me.