First of all, great module, this is a small, but effective tool when we want to customize submitted by string.

I know there's magic going on in "submitted_by_do_replace" function, it tries to cover all entity types, but i have case where it returns empty string. Comment has content, but there is no author.

Not sure if anyone else has this aswell, so i made a quick patch that i can at least use for my builds.

What it does, is, it checks the output from submitted_by_do_replace, if it's empty, it doesn't set $variables['submitted'] value.

   $submitted = submitted_by_do_replace($comment, '', 'comment');
    if (!empty($submitted)) $variables['submitted'] = $submitted;

Maybe author should take another look at submitted_by_do_replace "else" section, probably make specific rules for comments just like nodes and then else can fall in the rest. Maybe you can just check empty output for every place that the function is used, just like i do in this patch.

CommentFileSizeAuthor
#1 empty_comment-2335985-1.patch500 bytesJānis Bebrītis
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jānis Bebrītis’s picture

Issue summary: View changes
FileSize
500 bytes
Jānis Bebrītis’s picture

Status: Active » Needs review
Jānis Bebrītis’s picture

Issue summary: View changes
tkuldeep17’s picture

hi Jānis Bebrītis, Thanks for creating issue.
If you see drupal core comment module, in function 'template_preprocess_comment(&$variables)'
$variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['author'], '!datetime' => $variables['created']));

Now this module just overrides this variable, and by default it contains author. So if this module does not override this value, still $variables['submitted'] will contain author info. And if author does not exist so it will show empty string.
So I think there is no sense of adding this check.

NancyDru’s picture

Status: Needs review » Closed (works as designed)

No activity in 6 months