Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294951

Unhelpful error due to lack of validation

$
0
0

I recently ran into this rather cryptic error message:

Notice: Undefined property: stdClass::$_entity in Drupal\system\Plugin\views\row\EntityRow->pre_render() (line 123 of core/modules/system/lib/Drupal/system/Plugin/views/row/EntityRow.php).

In Drupal\system\Plugin\views\row\EntityRow:

<?php
 
public function pre_render($result) {
   
parent::pre_render($result);

    if (
$result) {
     
// Get all entities which will be used to render in rows.
     
$entities = array();
      foreach (
$result as $row) {
       
$entity = $row->_entity;
       
$entity->view = $this->view;
       
$entities[$entity->id()] = $entity;
      }

     
// Prepare the render arrays for all rows.
     
$this->build = entity_view_multiple($entities, $this->options['view_mode']);
    }
  }
?>

The initial value of $row->_entity is FALSE I believe, and if that's not populated with an entity by the time this code runs, the initial value of $entity is FALSE. What's crazy, is even if $entity is FALSE, $entity->view = $this->view will turn $entity into a stdClass.

Perhaps this is a symptom of a larger issue, but I'd think views could use more validation around this since this error message is always going to be confusing.


Viewing all articles
Browse latest Browse all 294951

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>