I've created a comment index to work around #1587912: Include reference to comments in Node metadata.

But in this new index, the commenter name is going into the search index as "Anonymous" rather than the name they entered on the comment form. I'm not confusing the comment author field, which is also going in correctly as "Anonymous".

I'm using Solr as my index, if that makes a difference.

-Joseph

Files: 
CommentFileSizeAuthor
#1 1637384--comment_name-1.patch554 bytesdrunken monkey
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es).
[ View ]
#1 1637384--comment_name_special_case-1.patch675 bytesdrunken monkey
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es).
[ View ]

Comments

Title:Commenter name going into index as "anonymous"Commenter name returns "Anonymous" for guests
Project:Search API» Entity API
Version:7.x-1.1» 7.x-1.x-dev
Component:Framework» Core integration
Status:Active» Needs review
StatusFileSize
new675 bytes
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es).
[ View ]
new554 bytes
PASSED: [[SimpleTest]]: [MySQL] 354 pass(es).
[ View ]

I love it when bugs aren't my fault …

The problem here lies in the Entity API module:

<?php
function entity_metadata_comment_get_properties($comment, array $options, $name) {
  switch (
$name) {
    case
'name':
      return
$name = ($comment->uid == 0) ? variable_get('anonymous', t('Anonymous')) : $comment->name;
?>

This will only return the name entered by the user if the user was logged in, otherwise it returns "Anonymous". It kinda looks like this was done deliberately, but I can't really see a reason, why. (Also, the completely effect-less $name = at the beginning of the line confuses me.)
Therefore, I'm leaving this as a bug report. I hope fago will be able to tell you more.

The first attached patch always just returns the entered name, which I'd say is what is expected of the property getter.
The second is my guess at what the special case's intention could've been – only use the entered name for anonymous users and use the user name for users which are logged in.

Status:Needs review» Reviewed & tested by the community

I tested the first patch. I think it is the appropriate one, since the second patch (the special case one) could produce confusion and unexpected values.

The patch works fine, of course. Very simple, straightforward change.

Thanks for the help,
-Joseph

Status:Reviewed & tested by the community» Fixed

I think the first patch is fine. committed that, thanks.

Status:Fixed» Needs work

Actually, to be consistent with what core does, we should append "(not verified)" to the user name if $comment->uid is empty.

I personally don't like that idea, since actually, that's *not* the commenter name as they left it. It's messing up the commenter name, and forcing me to un-mess it later.

Yes, I know that's how core does it. It irritates me there, too. :)

This is one place where I'd say to forget consistency.

-Joseph

I'd also be with jtbayly here. Core appends it when viewing the names, not internally. We are adding internal API functions here, which I think should return the data in a more basic form – as it's only used in code, not directly to display the name somewhere, whoever uses it can still attach that suffix, if they want.

I cannot find modules/callbacks.inc file,

I am using Drupal 7, am I doing anything wrong?

Issue summary:View changes

reworded & clarified