When I use comment edit link I get the following notice:

Notice: Undefined property: stdClass::$status in comment_access() (line 1427 of /var/www/delo/modules/comment/comment.module).

I looks like comment_access() expects $comment->status property, but we send just uid and cid. Attached patch fixes it.

Comments

bojanz’s picture

Title: "Notice: Undefined property" when using comment edit link » Stop passing around fake entities for comment, user, taxonomy access
Category: bug » task
Status: Needs review » Active

Retitling issue. We can't just send around fake entities. It causes trouble.
In #1172970: provide a unified way to retrieve result entities we added code that deals with this, and converted the node links to use it.

Now we need to do the same for comments, users, and taxonomy terms.
I think we should also have views_handler_field_entity_link that extends views_handler_field_entity, and then base all other link fields on that, so that we don't need to duplicate the:

  function option_definition() {
    $options = parent::option_definition();
    $options['text'] = array('default' => '', 'translatable' => TRUE);
    return $options;
  }

  function options_form(&$form, &$form_state) {
    $form['text'] = array(
      '#type' => 'textfield',
      '#title' => t('Text to display'),
      '#default_value' => $this->options['text'],
    );
    parent::options_form($form, $form_state);
  }

code that we have in views_handler_field_node_link, views_handler_field_comment_link, etc..

donquixote’s picture

Until then, can we not just comment_load() to fix the bug?
After all, comment_load() is cached, so we don't lose much.
Works for me..

slashrsm’s picture

You can still have a lot of overhead.....

Agree to fix this ASAP, though.

donquixote’s picture

You can still have a lot of overhead.....

Yup. But as I understand #1, the plan is to load the entity anyway?
How can you check access, without loading the entity? I know this used to work in D6 with nodes, but does it work with entities?

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new4.03 KB

Here is a small patch


$view = new view;
$view->name = 'comments';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'comment';
$view->human_name = 'comments';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'comments';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
/* Relationship: Comment: Content */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'comment';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['relationships']['nid']['required'] = 1;
/* Field: Comment: Title */
$handler->display->display_options['fields']['subject']['id'] = 'subject';
$handler->display->display_options['fields']['subject']['table'] = 'comment';
$handler->display->display_options['fields']['subject']['field'] = 'subject';
$handler->display->display_options['fields']['subject']['label'] = '';
$handler->display->display_options['fields']['subject']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['subject']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['subject']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['subject']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['subject']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['subject']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['subject']['alter']['trim'] = 0;
$handler->display->display_options['fields']['subject']['alter']['html'] = 0;
$handler->display->display_options['fields']['subject']['hide_empty'] = 0;
$handler->display->display_options['fields']['subject']['empty_zero'] = 0;
$handler->display->display_options['fields']['subject']['link_to_comment'] = 1;
/* Field: Comment: Approve link */
$handler->display->display_options['fields']['approve_comment']['id'] = 'approve_comment';
$handler->display->display_options['fields']['approve_comment']['table'] = 'comment';
$handler->display->display_options['fields']['approve_comment']['field'] = 'approve_comment';
/* Field: Comment: Delete link */
$handler->display->display_options['fields']['delete_comment']['id'] = 'delete_comment';
$handler->display->display_options['fields']['delete_comment']['table'] = 'comment';
$handler->display->display_options['fields']['delete_comment']['field'] = 'delete_comment';
/* Field: Comment: Edit link */
$handler->display->display_options['fields']['edit_comment']['id'] = 'edit_comment';
$handler->display->display_options['fields']['edit_comment']['table'] = 'comment';
$handler->display->display_options['fields']['edit_comment']['field'] = 'edit_comment';
/* Field: Comment: Reply-to link */
$handler->display->display_options['fields']['replyto_comment']['id'] = 'replyto_comment';
$handler->display->display_options['fields']['replyto_comment']['table'] = 'comment';
$handler->display->display_options['fields']['replyto_comment']['field'] = 'replyto_comment';
/* Field: Comment: View link */
$handler->display->display_options['fields']['view_comment']['id'] = 'view_comment';
$handler->display->display_options['fields']['view_comment']['table'] = 'comment';
$handler->display->display_options['fields']['view_comment']['field'] = 'view_comment';
/* Sort criterion: Comment: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'comment';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Comment: Approved */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'comment';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status_node']['id'] = 'status_node';
$handler->display->display_options['filters']['status_node']['table'] = 'node';
$handler->display->display_options['filters']['status_node']['field'] = 'status';
$handler->display->display_options['filters']['status_node']['relationship'] = 'nid';
$handler->display->display_options['filters']['status_node']['value'] = 1;
$handler->display->display_options['filters']['status_node']['group'] = 0;
$handler->display->display_options['filters']['status_node']['expose']['operator'] = FALSE;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'comments';
$translatables['comments'] = array(
  t('Master'),
  t('comments'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('Content'),
  t('Approve link'),
  t('Delete link'),
  t('Edit link'),
  t('Reply-to link'),
  t('View link'),
  t('Page'),
);
jtse’s picture

I get the following errors when applying dereine's patch. Also, Views 3.1 is out so re-rolling the patch may be necessary.

* Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1552 of /Users/jtse/workspaces/gorges/netway/public/guide/includes/bootstrap.inc).
* Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1552 of /Users/jtse/workspaces/gorges/netway/public/guide/includes/bootstrap.inc).
* Recoverable fatal error: Object of class stdClass could not be converted to string in views_handler_field_comment_link_delete->render_link() (line 16 of /Users/jtse/workspaces/gorges/netway/public/guide/sites/all/modules/views/modules/comment/views_handler_field_comment_link_delete.inc).

dawehner’s picture

Status: Needs review » Needs work

Thanks for the feedback, will try a bit later.

dealancer’s picture

I am having same erros as mentioned in comment #6 when applying patch from comment #5.

@derine, was this patch commited in views 7.x-3.1? If not, it looks like you mixed files when was making a diff.

BTW, here is another patch, which is temporary for me. Dot not use it, it could cause a performance issue, because of loading node entity.

dawehner’s picture

@derine, was this patch commited in views 7.x-3.1? If not, it looks like you mixed files when was making a diff.

I really like this kind of question, ... please read the comments :)

The patch still applies without problems so i guess you got confused by the diff format.

dawehner’s picture

Title: Stop passing around fake entities for comment, user, taxonomy access » Stop passing around fake entities for user, taxonomy access

I tested the patch again, and all comment links are working as expected.

Though there is still some work todo for the other handlers.

slashrsm’s picture

Status: Needs work » Needs review

Is there any performance impact since we load entire entity?

Besides that it looks OK.

Status: Needs review » Needs work

The last submitted patch, view_comment_edit_link-1440756-1292386-8.patch, failed testing.

slashrsm’s picture

Status: Needs work » Fixed

It looks like this was already fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.