Closed q2amarket closed 5 years ago
What should it be displaying instead? If the username is NULL that means it is an anonymous user (or one that was deleted).
What should it be displaying instead? If the username is NULL that means it is an anonymous user (or one that was deleted).
Well, within the core it may make sense as it is calling only when the users is exists or not. However, in some cases it returns Anonymous
when the data returns null as a handle value. For instance, I am using this $handles = qa_userids_to_handles($user_ids);
and using qa_get_one_user_html($handle)
in foreach
loop returning Anonymous
if array is null.
For now I have unset the value in my own code but it would be better to check within the core function.
Where are you getting the $user_ids
from? Surely wherever you get those from should be fetching valid user IDs only. If that's not possible, then you can check in your foreach loop rather than unset, for example:
$handles = qa_userids_to_handles($user_ids);
foreach ($handles as $handle) {
if ($handle === null) {
$html = ''; // or whatever you need to do if null
} else {
$html = qa_get_one_user_html($handle);
}
}
I think qa_get_one_user_html
is working as intended, changing it would break a bunch of other code that relies on displaying "anonymous".
Okay let me try once again to check as you mentioned. Actually, I have a bit different scenario and it is creating an issue. I have to unset the element.
Let me have a look and get back to you.
The issue I came up when was working on one plugin to render handle html. The function was returning
Anonymous
when the handle isNULL