Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The function comment_node_search_result (https://api.drupal.org/api/drupal/modules%21comment%21comment.module/fun...) never returns zero (or no string) when node comments are open.
In my opinion the last IF clause of the function should include an AND operator instead of an OR operator. How do you see it?
Thanks
Fèlix
Comments
Comment #1
vimalgoradiya CreditAttribution: vimalgoradiya commentedIn this "if ($node->comment != COMMENT_NODE_CLOSED || $comments > 0)" condition first he has check for comment is closed if comment is closed for the node no need to execute return function. While in second condition he has check for value is greater than 0 means return function need to execute. Second condition need to be true for the comment count. If both condition will mandatory return function never executed.
Comment #2
fcasanellas CreditAttribution: fcasanellas commentedThe problem is with nodes with open comments but zero comments at the moment.
In these cases first condition is true and the return function
return array('comment' => format_plural($comments, '1 comment', '@count comments'));
returns "1 comment"Comment #3
fcasanellas CreditAttribution: fcasanellas commentedComment #4
vimalgoradiya CreditAttribution: vimalgoradiya commentedFor this you need to refund format_plural function in api.drupal.org. format_plural function ensures that the string is pluralized correctly it formats a string containing a count of items. Otherwise return 1 comment.