i get some notices

Notice: Undefined index: comment_count in ohm_preprocess_node() (line 12 of /var/www/sites/all/themes/omega/ohm/preprocess/node.preprocess.inc).

and the following output in node teasers:

Friday, July 26, 2013 - 16:17 | Author: admin | Comments ()

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fubhy’s picture

Yep, confirmed. @splatio? Want to provide a fix? Probably just means to check for the comment variables in the node preprocessor?

Anthony Fok’s picture

Status: Active » Needs review
FileSize
747 bytes

I encountered the exact same problem as I was working on my website. It appears that #2042437: Undefined index: comment_count in ohm_preprocess_node() fixed the problem, but did not cover all cases.

Attached is a patch that uses a different way, !empty($node->comment_count), to detect the existence of comment_count. I borrowed this method from node_title_list() in module/node/node.module in Drupal 7 core, and it seems to work well here.

A side effect: "Comments (0)" is no more. That part would only be displayed if there is at least one comment posted for that node.

fubhy’s picture

What you wrote there is the exact same logic just with different (nicer) code.

isset($foo) && $foo === !empty($foo)

;)

fubhy’s picture

I think having "Comments (0)" is something we should try to retain. So we need a different solution. I am sure there is a better way. Will look into it tomorrow unless you want to try again Anthony? :)

Anthony Fok’s picture

Thanks for the encouragement, and the big hint that you gave me. ;-)
The patch is now revised to keep "Comments (0)".
Please review. Many thanks!

Anthony Fok’s picture

Sorry, I made a huge "Brown Paper Bag" mistake... I updated my test theme without actually updating the copy in the git tree before making the patch... (very embarrassed) ;-)

Here is the patch again. Thanks!

Anthony Fok’s picture

Another revised patch that (I hope) follows the DRY principle better. :-)

fubhy’s picture

Looks good. Did not test it though. Does this work now in all situations?

Anthony Fok’s picture

Yes, it works well here on my computer. Perhaps other people can help test it too.

fubhy’s picture

Status: Needs review » Fixed

Committed, thanks.

Status: Fixed » Closed (fixed)

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