8: Undefined index: label, xxx/Themes/default/GenericMenu.template.php (Line 121)
Description
On occasion, I get an "Undefined index: label" error in the log. In this instance, the user is a global moderator, but doesn't have many of the moderation permissions.
Environment (complete as necessary)
- Version/Git revision: Current GH
- Database Type: MySQL
- Database Version: 8.0
- PHP Version: 8.1
Additional information/references
At issue is this logic: https://github.com/SimpleMachines/SMF/blob/e8c7800eadb6a41e5b87ec2d11a1e34f959bc392/Sources/Subs-Menu.php#L233
Under certain (rare) circumstances, it can get to that logic without $first_sa and $last_sa being set. E.g., if the user doesn't have permission to do any of the activities in the submenu. First & last end up getting set on an undefined/null new entry. The template can't find the label, because it is null:

Do we really need is_first and is_last? This seems like a hold over from when we couldn't handle this with pure CSS. If we need it we should be able to use array_key_first and array_key_last.
Good point.
I'm still confused why it's building this menu at all. It's not displayed. And this error comes from clicking for the alert popup.
@live627 - I ended up taking a stab at this...