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.
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
Comment | File | Size | Author |
---|---|---|---|
#1 | 1637384--comment_name-1.patch | 554 bytes | drunken monkey |
#1 | 1637384--comment_name_special_case-1.patch | 675 bytes | drunken monkey |
Comments
Comment #1
drunken monkeyI love it when bugs aren't my fault …
The problem here lies in the Entity API module:
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.
Comment #2
jtbayly CreditAttribution: jtbayly commentedI 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
Comment #3
fagoI think the first patch is fine. committed that, thanks.
Comment #4
Damien Tournoud CreditAttribution: Damien Tournoud commentedActually, to be consistent with what core does, we should append "(not verified)" to the user name if
$comment->uid
is empty.Comment #5
jtbayly CreditAttribution: jtbayly commentedI 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
Comment #6
drunken monkeyI'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.
Comment #7
majidkh CreditAttribution: majidkh commentedI cannot find modules/callbacks.inc file,
I am using Drupal 7, am I doing anything wrong?
Comment #7.0
majidkh CreditAttribution: majidkh commentedreworded & clarified