Missing OgRole fails in UI

Created on 1 April 2025, 20 days ago

Problem/Motivation

Accessing the OG role permissions form results in a fatal error when the OG role object is not available.

The website encountered an unexpected error. Try again later.

Error: Call to a member function getLabel() on null in Drupal\og_ui\Form\OgRolePermissionsForm->rolePermissionTitleCallback() (line 44 of /var/www/html/og_ui/src/Form/OgRolePermissionsForm.php).

call_user_func_array(Array, Array) (Line: 58)
Drupal\Core\Controller\TitleResolver->getTitle(Object, Object) (Line: 204)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}(Array) (Line: 245)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

  1. Install and enable the og and og_ui modules.
  2. Create a group content type and add an OG group.
  3. Visit the OG role permissions page (e.g., /admin/config/group/permissions/node/committee/does-not-exist) for a non-existent or invalid role ID.
  4. Observe the error: Call to a member function getLabel() on null.

Proposed resolution

Maybe copy what core does... we'll see

User interface changes

None expected. The fix will prevent a fatal error and ensure the intended permissions UI loads or fails gracefully.

🐛 Bug report
Status

Active

Version

2.0

Component

og.module

Created by

🇨🇦Canada joelpittet Vancouver

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