Heyho.

At first: I´m very gladful that these module exists ;)

I use AJAX Comments with Inline AJAX Comments für my organic groups.
If I load a group there are these two error messages, no matter how much comments or group contents there are.

Notice: Undefined property: stdClass::$content in ajax_comments_panels_pane_content_alter() (Zeile 326 von ...\sites\all\modules\ajax_comments\ajax_comments.module).

Notice: Undefined property: stdClass::$content in ajax_comments_panels_pane_content_alter() (Zeile 326 von ...\sites\all\modules\ajax_comments\ajax_comments.module).

May be its helpful to know it.
If I shoul add some information, please tell it.

cya
Garm

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dagomar’s picture

Issue summary: View changes
FileSize
577 bytes

This had me stumped for a bit. What happens here is that in some cases there will be no content, because of comment settings. In these cases we can assume no AJAX Comments functionality is necessary because:

1. Comment setting is closed and no previous comments exist.
2. Previous comments exist and comment setting is set to hidden.

We simple do not want AJAX Comments to do anything if $content->content is not set. I've added a patch.

dagomar’s picture

Version: 7.x-1.0-alpha1 » 7.x-1.x-dev
Status: Active » Needs review
dagomar’s picture

Status: Needs review » Needs work

Silly me, if there are no comments yet, this won't print the needed div. I'll rework and post this later, I need this working today, but ignore the patch in #2

dagomar’s picture

Here is a new patch. I needed to check the context to see if the comments need to be printed or not. It follows exactly how Drupal does this on it's own, with the exception of when commenting is allowed but no comments have been made yet. In that case the pane needs to be printed, thus only rendering the title. I think it would be nice to have some initial content there ('Be the first to post a reaction' - or something like that). For that some extra refacturing is needed because that text needs to be removed after a first comment is posted. Another option could be to empty the title, I think... But perhaps this is not the place for that.

if(empty($content->content)) {
# We cannot be sure about the context's key, hence the array_values here.
  $context = array_values($context);
# Since we're working with comments, there has to be a node.
  $node = $context[0]->data;
# Conditions when not to print anything
  if($node->comment == 0 || ($node->comment == 1 && $node->comment_count == 0)) {
      return;
  } 
}
dagomar’s picture

Status: Needs work » Needs review
jweowu’s picture

I note that the function still tries to use content->content if it makes it past the code you've added, but your code never sets that property.

I haven't examined what you're doing here, but can you confirm whether you've ensured that, if it gets that far, there's definitely a content property to use?

(e.g. If the call to ctools_content_render() in render_pane_content() returns NULL)

There are some coding standards formatting issues to fix up, in any case.

jweowu’s picture

I've re-written that patch (coding standards formatting; use of COMMENT constants; allow for $content being NULL).

The bit I'm not sure of is obtaining the node from $context. I didn't like the assumption that the first element of the context array held a node, but I also got lost in the ctools context code looking for a way to ask explicitly for a 'node' or 'entity:node context' (although it's also not clear to me whether those are the only possibilities). I've gone with something which I think is better than before, but could be improved if a suitable API call does exist.

jweowu’s picture

(see previous comment)

formatC'vt’s picture

Status: Needs review » Postponed (maintainer needs more info)

try latest release please

jweowu’s picture

It looks like the relevant code for this issue has been refactored out of existence, so we should probably close this issue.

formatC'vt’s picture

Status: Postponed (maintainer needs more info) » Fixed

ok

Status: Fixed » Closed (fixed)

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