I have a view where I get the relevant nodes via a relationship from an Entity Reference field. Now when I want to get the Disqus comment count with the views field using the relationship, I get this error: "Notice: Undefined property: stdClass::$nid in views_handler_field_node_disqus_comment_count->render() (Line 39 of [...]/sites/all/modules/contrib/disqus/disqus.views.inc)." That's caused by the field handlers render method trying to access $values->nid, but that does not exist, because the field containing the nid is coming from the relationship, so it is actually stored in $values->node_field_data_field_entityreference_nid (where field_entityreference would be the field holding the reference to the relevant nodes).

Something is wrong in the handler, I think it has to do with overriding the query method with an empty method. I removed that and changed the real_field in the init method to 'nid', because that is the actual field we need to make the render method work. I really don't know what I am doing, but my patch does work for me as far as I can see.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

slashrsm’s picture

Version: 7.x-1.9 » 7.x-1.x-dev
Priority: Normal » Major
Status: Active » Needs work
+++ b/disqus.views.incundefined
@@ -36,7 +33,7 @@ class views_handler_field_node_disqus_comment_count extends views_handler_field
-    $node = node_load($values->nid);
+    $node = node_load($values->_field_data[$this->field_alias]['entity']->nid);

Why not

$node = node_load($values->{$this->field_alias});
jockium’s picture

Same problem here...
However the proposed patch doesn't work...

the node comes from a relasionship ( Taxonomy term: Content with term ), but "$this->field_alias" has a value of "unknown"

Any ideas anyone?

evanjenkins’s picture

I was able to fix this issue with the attached patch.