Posted by jtbayly on June 15, 2012 at 12:28pm
5 followers
| Project: | Entity API |
| Version: | 7.x-1.x-dev |
| Component: | Core integration |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
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
Comments
#1
I love it when bugs aren't my fault …
The problem here lies in the Entity API module:
<?phpfunction 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.
#2
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
#3
I think the first patch is fine. committed that, thanks.
#4
Actually, to be consistent with what core does, we should append "(not verified)" to the user name if
$comment->uidis empty.#5
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
#6
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.
#7
I cannot find modules/callbacks.inc file,
I am using Drupal 7, am I doing anything wrong?