Problem/Motivation
When accessing the path group_hierarchy route (path: /admin/group/group-hierarchy) the following fatal error is hit:
TypeError: Drupal\group_hierarchy\Controller\GroupHierarchyController::buildTree(): Argument #2 ($group_hierarchy) must be of type array, null given, called in /var/www/html/web/modules/contrib/group_hierarchy/src/Controller/GroupHierarchyController.php on line 119 in Drupal\group_hierarchy\Controller\GroupHierarchyController->buildTree() (line 191 of /var/www/html/web/modules/contrib/group_hierarchy/src/Controller/GroupHierarchyController.php)
#0 /var/www/html/web/modules/contrib/group_hierarchy/src/Controller/GroupHierarchyController.php(119): Drupal\group_hierarchy\Controller\GroupHierarchyController->buildTree(Array, NULL)
#1 [internal function]: Drupal\group_hierarchy\Controller\GroupHierarchyController->build()
#2 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#3 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#4 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#5 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#6 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#7 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#8 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#9 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#11 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#17 {main}
Steps to reproduce
- Enable the module
- Create two groups
- Create a hierarchy
- Access the given route
- Observe bug
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | After_Patch_Applied_Errors_Resolved.PNG | 44.08 KB | jay jangid |
| #5 | Before_Patch_Showing_Errors.PNG | 58.75 KB | jay jangid |
| #3 | After_patch.png | 238.95 KB | akram khan |
| #3 | Before_patch.png | 739.4 KB | akram khan |
| #2 | group_hierarchy-error_when_accessing_group_hierarchy_route-3374016-2.diff | 2.38 KB | jaypan |
Issue fork group_hierarchy-3374016
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jaypanComment #3
akram khanI reviewed the patch and it's resolved the issue. Before patch when i try to access the (path: /admin/group/group-hierarchy) it gives TypeError and after applying patch the page appear successfully. Additionally, I have attached before and after state screenshots for reference.
Comment #4
jay jangid commentedComment #5
jay jangid commentedI have reviewed and implemented the Patch provided by @Jaypan.
The Patch has been applied successfully on Drupal 9.5.x.
Now errors are removed which is shown before applying the patch.
I am sharing screenshots for your reference.
Please review.
Thank You.
Comment #6
jaypanComment #7
jdleonardPatch appears to work for me on Drupal 10.1.1. Thanks!
Comment #9
facine commentedFixed, thanks!