My View spews a bunch of these:
Notice: Trying to get property of non-object in views_handler_field_comment_link->render_link() (regel 55 van sites/all/modules/contrib/views/modules/comment/views_handler_field_comment_link.inc).
Notice: Trying to get property of non-object in views_handler_field_comment_link->render_link() (regel 56 van sites/all/modules/contrib/views/modules/comment/views_handler_field_comment_link.inc).
Notice: Trying to get property of non-object in comment_access() (regel 1447 van modules/comment/comment.module).
Notice: Trying to get property of non-object in views_handler_field_comment_link_edit->render_link() (regel 48 van sites/all/modules/contrib/views/modules/comment/views_handler_field_comment_link_edit.inc).
because my View has a Comment: Child comment relationship that doesn't always return a comment.
views_handler_field_comment_link::render() doesn't check if there's a comment to render an edit link for:
function render($values) {
$value = $this->get_value($values, 'cid');
return $this->render_link($this->sanitize_value($value), $values);
}
The above $value is empty if there's no comment, the cid otherwise.
Fix is easy:
function render($values) {
$value = $this->get_value($values, 'cid');
if (!$value) {
return '';
}
return $this->render_link($this->sanitize_value($value), $values);
}
If there's no comment, don't render an edit link.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | views-comment-link-errors-2542798-1.patch | 1.97 KB | jantoine |
Comments
Comment #1
jantoine commentedI just ran into the same issue, however the suggested fix doesn't just change the edit link, but changes the view link as well breaking the 'Link field to the node if there is no comment.' feature. The attached patch fixes all errors without breaking features and also prevents the edit link from appearing if there is no comment.
Comment #2
jantoine commentedComment #3
jantoine commentedComment #4
rudiedirkx commentedYou mean this part?
Yeah, I didn't check there. Looks good, but can't try it right now.
Comment #5
rudiedirkx commentedI get these:
because
$nidis defined in theif, and used in anotherelseif.If there's no comment to link to, there's no way of knowing the (alleged) parent nid. I dont think the If there is no comment link to the node part is possible.