SMF icon indicating copy to clipboard operation
SMF copied to clipboard

8: Undefined index: label, xxx/Themes/default/GenericMenu.template.php (Line 121)

Open sbulen opened this issue 3 years ago • 2 comments

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: image

sbulen avatar Oct 08 '22 20:10 sbulen

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.

jdarwood007 avatar Oct 09 '22 00:10 jdarwood007

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.

sbulen avatar Oct 10 '22 03:10 sbulen

@live627 - I ended up taking a stab at this...

sbulen avatar Apr 22 '23 21:04 sbulen