Fixed User Mentions sometimes generate errors

Xon

Well-known member
If a post has a valid user mention, and then a user mention which is too long, the tagging dies.

This is because of the length test in XenForo_Model_UserTagging::_getTagMatchUsers:
Code:
		foreach ($matches AS $key => $match)
		{
			if (utf8_strlen($match[1][0]) > 50)
			{
				// longer than max username length
				continue;
			}
...
		}
...
			foreach ($matchKeys AS $key)
			{
				if ($user["match_$key"])
				{
					$usersByMatch[$key][$user['user_id']] = $userInfo;
				}
			}
The line "if ($user["match_$key"])" is at fault, as that key will never exist because it's generator was skipped.

This needs to be wrapped in an !empty() or isset() && $value guard.
 
We had this reported once before, but didn't have the reproduce case so didn't manage to trigger it. But no problem reproducing it here with the explanation. Fixed now, thanks. :)
 
Top Bottom