Thanks Marco.3Di wrote: ↑Thu Feb 23, 2017 12:22 am Hi Javier,
in case of "delete user but retain posts" the only reference you could play with is the index post_username in the POSTS table, the poster_id will be set to ANONYMOUS (1).
Like adding a vote_user_name to the VOTES_TABLE and do some magic.
If you retain posts whilst deleting an user IMO the votes should be retained as well, removed in case of "delete user and posts". But that's just my opinion.
Regards.
I have reviewed the core, and the fact is that regardless of the delete user option (retain or delete posts), the votes table remains intact. But, as you said, there is no way to restore the username (unless you store them in the poll votes table, as you suggested, but IMO that would be overkill).
So, I am inclined to leave it alone, and "just" consider those votes as guest votes always. If you see guest votes in a poll that does not allow voting to guests, and you had deleted a user... Well, it's either that, or not much more (deleting votes during user deletion could be an option, but very costly, for almost no benefit).
Quick and dirty hack (I will provide a more definite fix in the next rev):
Around line 700, after
{
and before a call to to get_username_string
, add the following:
Code: Select all
if (!isset($user_cache[$voter_id]['total_user_votes']))
{
continue;
}
{
and before a call to to get_username_string
, add the following:
Code: Select all
if (!isset($voter_data['total_user_votes']))
{
continue;
}
-javiexin