The original code is wrong but I think we should fix it. That foreach inside a foreach and then assign the original non-modified `$items` is one of the most epic fails I've seen in Joomla!