Error: Typed property MenuName accessed before initialization

Created on 5 October 2023, about 1 year ago

Problem/Motivation

When saving a node associated with an OG menu instance, the OgMenuBlock Plugin throws an error at the first load since the property does not exists yet. Upon reload, the property was cached and the page render as expected.

Steps to reproduce

Setup
- Drupal 10.1.x
- PHP 8.2.3
- Organic groups 8.x-1.0-alpha10

Create a new node that's associated with an OG and add it to the Group's menu. Save the node and you should get the following error:

The website encountered an unexpected error. Please try again later.

Error: Typed property Drupal\og_menu\Plugin\Block\OgMenuBlock::$menuName must not be accessed before initialization in Drupal\og_menu\Plugin\Block\OgMenuBlock->getMenuName() (line 315 of modules/contrib/og_menu/src/Plugin/Block/OgMenuBlock.php).

Proposed resolution

initialize the $menuName property in the constructor of the OgMenuBlock class

Remaining tasks

Add code to src/Plugin/Block/OgMenuBlock.php

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇧🇷Brazil barone Belo Horizonte

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024