A member just reported that from notification by email from mentions and likes REALNAME is displayed instead of the member name. I initially thought it was related to translations but everything seems translated fine. So in my profile I changed language from Italian to English and here is what I received :
{REALNAME},
this email is to to inform you that test1 has just has liked the message https://www.skodaclub.it/index.php?msg=147081 at Skoda Club Italia.
Saluti,
Il team di Skoda Club Italia.
As you can see there is mixed content, in English and also Italian.
/me blames... someone! O:-)
In /sources/subs/MentionType/MentionMessageAbstract.php, the following two lines:
$langstrings = $this->_loadStringsByTemplate($template, $members, $members_data, $lang_files, $replacements);
$replacements['REALNAME'] = $members_data[$member]['real_name'];
should be:
$replacements['REALNAME'] = $members_data[$member]['real_name'];
$langstrings = $this->_loadStringsByTemplate($template, $members, $members_data, $lang_files, $replacements);
I get an error when mentioning a member if I do that edit:
Warning: Illegal offset type in /public/sources/subs/MentionType/MentionMessageAbstract.php on line 205
Warning: Illegal offset type in /public/sources/subs/MentionType/MentionMessageAbstract.php on line 205
and line 205 is
{
$langs[$users_data[$user]['lngfile']] = $users_data[$user]['lngfile'];
}
The email sent is empty, no subject and no text.
I also found these errors in elkarte log https://screenshots.firefox.com/3aUHkn25c9NJHPUc/www.skodaclub.it
test1 is the member I used to make the tests. With test1 I mentioned my account which has the notifications enabled by email for likes, mentions, etc
Seems strange that this is caused by the fix I proposed, at least I can't see any reason that the replacement I suggested could induce this error.
The other set of errors are interesting, but... I see something wrong, but needs investigation.
Problem solved, or at least one problem was solved :)
The line code you mentioned does not exist:
$langstrings = $this->_loadStringsByTemplate($template, $members, $members_data, $lang_files, $replacements);
is actually:
$langstrings = $this->_loadStringsByTemplate($template, $keys, $members, $members_data, $lang_files, $replacements);
so it was enough to invert those 2 lines like you suggested and the notification for a liked message arrives correctly.
Now if someone @mention me I get this message by mail:
radu,
la presente email รจ per avvisarti chea ha appena citato un tuo messaggio in https://www.skodaclub.it/index.php?msg=188466 su Skoda Club Italia.
Saluti,
Il team di Skoda Club Italia.
My nick is correct, but is missing the author of the mention.
Ouch!
I guess I hit ctrl+backspace by mistake... :-[
Sorry.
hmm... is the quote the only one where the name doesn't appear?
The other mails seemed fine, but I'll do another test just to be sure.
Found, yes, this and the mention were affected.
In both case:
'ACTIONNAME' => $this->_task['notifier_data']['name'],
should become:
'ACTIONNAME' => $this->_task['source_data']['notifier_data']['name'],
files affected:
sources/subs/MentionType/QuotedmemMention.php
sources/subs/MentionType/MentionmemMention.php
Ok, I just tested:
- Likes - works fine with the edit suggested
- Mention - works fine with the edit suggested
- Quote - works fine with the edit suggested
- Add buddy - works fine
- UnLike (like removed) - no email received even if immediate notification is active on my profile and also available in ACP
There is also this notification "Notify when email notifications are disabled (mention only)" which I don't know what exactly does and how to test it.
Edit: while you are looking at QuotedmemMention.php you may want to clean the code by removing the lines 115-136 ;)
I think this was left without email on purpose... I'm not sure about the rationale.
Not really, there is no test yet. :P
At this point should be better to remove this option from Acp and notifications in user profile.