If i use realname module - i can't send messages. There some issues relate to autocomplete widget
1. checkPrivateMessageMemberExists method in Mapper\PrivateMessageMapper.php. method can't find user by his realname. so, when you open add message form - validation of user name fails.
2. even if validation if checkPrivateMessageMemberExists success, after submit form appearing message "There are no entities matching "USERNAME". Origin in validateEntityAutocomplete (Drupal/Core/Entity/Element/EntityAutocomplete.php) which don't get uid in username, because submitted name don't have it. Submitted value is "USERNAME", instead of "USERNAME (UID)". When form loaded in first time i can see that http://prntscr.com/k8ypcn (default value like "USERNAME (UID)"), but if check value, it's already will be without uid http://prntscr.com/k8ypui . So, some javascript change it.
Hope this help and someone can continue searching to fix this incompatibility with realname module.
Problem in private_message_members_widget.js, in init method. addUserToMembers called without uid.
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | private_message-2987189--MR121-24.patch | 4.11 KB | loze |
| #5 | private-message-entity-reference-bug.patch | 209.96 KB | adam clarey |
Issue fork private_message-2987189
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2987189-realname
changes, plain diff MR !175
- 2987189-realname-support
changes, plain diff MR !121
Comments
Comment #2
cosolom commentedComment #3
cosolom commentedComment #4
cosolom commentedComment #5
adam clarey commentedThis issue exists in version 8-1.2 too.
It can't find the entity references because the (uid) is removed. I've attached a patch that makes realname integration possible in 1.2, i suspect something similar can be used for version 2
Comment #6
phjouAccording to the documentation of the module, only the 2.x branch should receive new features.
Moreover the patch is completely wrong, I suppose it should only bring this change:
I am not sure what this change implies.
Comment #7
madelyncruz commentedThis issue still exists in 8.x-1.2. I've looked at the file
/private_message/js/private_message_members_widget.js. It looks like that the code change for$(this).val(username);has been merged, but looks like it does not fixed the issue.Comment #8
ekulkisnek commentedi had the same problem and i used private_message_module_implements_alter() to prevent all realname hooks from occurring in the private message module. realnames do not show up in private message threads but it allows for realname use on the rest of the site. i'm currently working on a way to display the realname in threads. if you've found a better fix or can help with that let me know
Comment #9
authintmedia commentedPrivate Message is not incompatible with realname module. It is incompatible with the username format that is displayed.
If you leave the default setting of the realname to [user:account-name] everything works as expected.
Any modification to how username is displayed makes it impossible to use private message.
Comment #10
loze commentedThis one line patch get it to not break with realname, but it would be nice to fully support it so we can display realnames.
I briefly looked at the js and saw there are several places where it pulls the username from the val() of an element, I feel it should be pulling the username form the data attribute when it needs it, this way we can still show the realname to the user.
If no one is already working on this, I'll try to dig into it in the coming weeks as I would like to use this module for a project.
has there been any progress on this from the maintainers?
Comment #11
loze commentedOk, so I sat with it for a bit and I think I got it. It was much simpler than I thought it would be,
This patch makes it work with realname, both with the name validation and the autocomplete.
Ignore the previous patch.
I'm not sure if there is a cleaner way to do the query part that I altered, but it works.
Comment #12
phjouI like the fact that the display name is now split from the username value.
Please remove:
console.log(usernameInput, 'usernameInput');Comment #13
loze commentedMy bad, here ya go.
Comment #14
phjouThanks. I will have to find some time to test the patch on an installed Drupal.
It would be awesome to have a test to be sure it is working with or without realname. This module is huge and we have almost no tests.
Comment #15
nishruu commentedHi.
The displayed name was not inserted if the user used the down key and enter, so I added a small modification to the patch.
Apart from that, I think there's still one problem left : when we reload the page, the logic in the init() function retrieves the username to recreate the user tags, not the displayname.
I tried to add a data-displayname attribute to the input tag, but it cannot be preserved between page refresh so it was useless. I suppose we could make an ajax call to convert the usernames to the matching displaynames before recreating the tags ?
Comment #16
phjou@Nishruu I think that the one problem left you are talking about might be that one? #3098859: The members widget is broken
Comment #17
drupgirl commented+1 for a 8.x-3.x patch - edited - this patch is in the latest
Comment #18
loze commentedComment #22
loze commentedIts been some time since the original issue and patches.
Since then this module now uses the users display name instead of the username, which resolves 1/2 of what was being addressed in the original patches.
I have created MR!121 which adds realname support to the autocomplete query for the members widget if realname is installed.
here is a patch for the MR to use with composer.
Comment #23
loze commentedComment #24
loze commentedLast patch in #22 was wrong, some unintended changes made it in there.
this one should work with composer
Comment #25
claudiu.cristeaIsn't this reduced to the idea of using User::getDisplayName()?
Comment #26
loze commented@claudiu.cristea I dont believe that getDisplayName() is a queryable field, right?
I'm trying to get the auto complete search to use the compiled display name that is stored in the realname table. Otherwise the search is limited to the username which in my case my users dont know.
Comment #27
claudiu.cristeaThank you. I think you're right. I'm not a very big fan of adding module soft dependencies (aka "if module exists..."). Is there any way you can hook in from a 3rd-party and alter the suggestions? At least maybe we can create a submodule to add realname support. I admit I didn't have time to give a deeper look at this
Comment #28
loze commentedThanks. Since the original post, this module now has its own entity reference selection plugin instead of using a direct query. So I created an issue in realname to support private_message which is just a small change and it appears to be working with the 3.0 branch.
#3501017: Private Message module support
Comment #30
claudiu.cristeaI think now, with 4.x, it still can be fixed here.
Comment #32
claudiu.cristeaComment #33
claudiu.cristea@loze, could you please try MR!175 but without the Real Name patch?
Comment #34
loze commentedYes, MR!175 does appear to do the job with version 4.0 alpha
thanks!
Comment #35
claudiu.cristeaThank you, @loze
I have fixed also the schema alteration for
default:userplugin settings just in case. I will merge this MR as soon as you test again the latest version MR against 4.0.0-alpha1 and confirm that works as expected by setting this issue status to RTBCComment #36
loze commentedTested with alpha2 and dev and it seems to do the trick. Thanks!
Comment #38
claudiu.cristeaMerged. Thank you!
Comment #39
claudiu.cristeaIncluded in 4.0.0-alpha3