- Issue created by @Nathan Tsai
- Status changed to Postponed: needs info
almost 2 years ago 7:55am 10 May 2023 - 🇮🇳India samit.310@gmail.com
Hi @Nathan Tsai,
I am not able to reproduce this at my end, Looks like there is some module's version issue.
The
nodeaccess_node_access
function is not exists in nodeaccess.module file. also nodeaccess.module file only have 204 lines of code.following, I am adding a line of code you added in the description.
Warning: Undefined array key "rid" in nodeaccess_node_access() (line 276 of /home/{USER}/public_html/modules/contrib/nodeaccess/nodeaccess.module)
- 🇨🇦Canada OMD
I'm getting the same error for content that is not protected by node access:
Node Access Version: 8.x-1.1
Drupal Version 9.5.9Warning: Undefined array key "rid" in nodeaccess_node_access() (line 276 of /var/www/html/drupal/web/modules/contrib/nodeaccess/nodeaccess.module)
#0 /var/www/html/drupal/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real()
#1 /var/www/html/drupal/web/modules/contrib/nodeaccess/nodeaccess.module(276): _drupal_error_handler()
#2 [internal function]: nodeaccess_node_access()
#3 /var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(426): call_user_func_array()
#4 /var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
#5 /var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(433): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#6 /var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php(97): Drupal\Core\Extension\ModuleHandler->invokeAll()
#7 /var/www/html/drupal/web/core/modules/node/src/NodeAccessControlHandler.php(105): Drupal\Core\Entity\EntityAccessControlHandler->access()
#8 /var/www/html/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(710): Drupal\node\NodeAccessControlHandler->access()
#9 /var/www/html/drupal/web/core/modules/node/src/Entity/Node.php(195): Drupal\Core\Entity\ContentEntityBase->access()
#10 /var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityAccessCheck.php(68): Drupal\node\Entity\Node->access()
#11 [internal function]: Drupal\Core\Entity\EntityAccessCheck->access()
#12 /var/www/html/drupal/web/core/lib/Drupal/Core/Access/AccessManager.php(160): call_user_func_array()
#13 /var/www/html/drupal/web/core/lib/Drupal/Core/Access/AccessManager.php(136): Drupal\Core\Access\AccessManager->performCheck()
#14 /var/www/html/drupal/web/core/lib/Drupal/Core/Access/AccessManager.php(93): Drupal\Core\Access\AccessManager->check()
#15 /var/www/html/drupal/web/core/lib/Drupal/Core/Menu/LocalTaskManager.php(327): Drupal\Core\Access\AccessManager->checkNamedRoute()
#16 /var/www/html/drupal/web/core/lib/Drupal/Core/Menu/LocalTaskManager.php(358): Drupal\Core\Menu\LocalTaskManager->getTasksBuild()
#17 /var/www/html/drupal/web/core/lib/Drupal/Core/Menu/Plugin/Block/LocalTasksBlock.php(95): Drupal\Core\Menu\LocalTaskManager->getLocalTasks()
#18 /var/www/html/drupal/web/core/modules/block/src/BlockViewBuilder.php(171): Drupal\Core\Menu\Plugin\Block\LocalTasksBlock->build()
#19 [internal function]: Drupal\block\BlockViewBuilder::preRender()
#20 /var/www/html/drupal/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array()
#21 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback()
#22 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback()
#23 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
#24 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#25 /var/www/html/drupal/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render()
#26 /var/www/html/drupal/web/sites/default/files/php/twig/6481d54819d62_page.html.twig_tLX3lPAG5dWYGtWw8b8JXWQEv/aKal22MJHFblo_i_SqOXTNdTm10wA5vPCmOGlMswQkI.php(83): Drupal\Core\Template\TwigExtension->escapeFilter()
#27 /var/www/html/drupal/vendor/twig/twig/src/Template.php(405): __TwigTemplate_3e135de154d5de9377e6dc85c6165ee7->doDisplay()
#28 /var/www/html/drupal/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling()
#29 /var/www/html/drupal/vendor/twig/twig/src/Template.php(390): Twig\Template->display()
#30 /var/www/html/drupal/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render()
#31 /var/www/html/drupal/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
#32 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
#33 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#34 /var/www/html/drupal/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render()
#35 /var/www/html/drupal/web/sites/default/files/php/twig/6481d54819d62_html.html.twig_6hWXcJ1V-Qz6Co4MgIuQvr8BF/GeseC_Qu_u9SIMKWzBHNuUex80uZo4d_6Km3UlI_UFQ.php(109): Drupal\Core\Template\TwigExtension->escapeFilter()
#36 /var/www/html/drupal/vendor/twig/twig/src/Template.php(405): __TwigTemplate_9820deedac8deb08ba334f2bbd93e4f8->doDisplay()
#37 /var/www/html/drupal/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling()
#38 /var/www/html/drupal/vendor/twig/twig/src/Template.php(390): Twig\Template->display()
#39 /var/www/html/drupal/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render()
#40 /var/www/html/drupal/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
#41 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
#42 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#43 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(162): Drupal\Core\Render\Renderer->render()
#44 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#45 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(163): Drupal\Core\Render\Renderer->executeInRenderContext()
#46 /var/www/html/drupal/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()
#47 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
#48 /var/www/html/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
#49 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(174): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#50 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#51 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#52 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#53 /var/www/html/drupal/web/modules/contrib/cleantalk/src/EventSubscriber/BootSubscriber.php(187): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#54 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\cleantalk\EventSubscriber\BootSubscriber->handle()
#55 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#56 /var/www/html/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#57 /var/www/html/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#58 /var/www/html/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#59 {main} - 🇨🇦Canada OMD
I'm getting a similar warning triggered by line 276 as well. Not sure if it's related but there's the warning info from drupal log. Oddly this is being triggered on a node that is not access controlled.
Warning: Trying to access array offset on value of type null in nodeaccess_node_access() (line 276 of /var/www/html/drupal/web/modules/contrib/nodeaccess/nodeaccess.module)
#0 /var/www/html/drupal/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real()
#1 /var/www/html/drupal/web/modules/contrib/nodeaccess/nodeaccess.module(276): _drupal_error_handler()
#2 [internal function]: nodeaccess_node_access()
#3 /var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(426): call_user_func_array()
#4 /var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
#5 /var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(433): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#6 /var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php(97): Drupal\Core\Extension\ModuleHandler->invokeAll()
#7 /var/www/html/drupal/web/core/modules/node/src/NodeAccessControlHandler.php(105): Drupal\Core\Entity\EntityAccessControlHandler->access()
#8 /var/www/html/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(710): Drupal\node\NodeAccessControlHandler->access()
#9 /var/www/html/drupal/web/core/modules/node/src/Entity/Node.php(195): Drupal\Core\Entity\ContentEntityBase->access()
#10 /var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityAccessCheck.php(68): Drupal\node\Entity\Node->access()
#11 [internal function]: Drupal\Core\Entity\EntityAccessCheck->access()
#12 /var/www/html/drupal/web/core/lib/Drupal/Core/Access/AccessManager.php(160): call_user_func_array()
#13 /var/www/html/drupal/web/core/lib/Drupal/Core/Access/AccessManager.php(136): Drupal\Core\Access\AccessManager->performCheck()
#14 /var/www/html/drupal/web/core/lib/Drupal/Core/Access/AccessManager.php(93): Drupal\Core\Access\AccessManager->check()
#15 /var/www/html/drupal/web/core/lib/Drupal/Core/Menu/LocalTaskManager.php(327): Drupal\Core\Access\AccessManager->checkNamedRoute()
#16 /var/www/html/drupal/web/core/lib/Drupal/Core/Menu/LocalTaskManager.php(358): Drupal\Core\Menu\LocalTaskManager->getTasksBuild()
#17 /var/www/html/drupal/web/core/lib/Drupal/Core/Menu/Plugin/Block/LocalTasksBlock.php(95): Drupal\Core\Menu\LocalTaskManager->getLocalTasks()
#18 /var/www/html/drupal/web/core/modules/block/src/BlockViewBuilder.php(171): Drupal\Core\Menu\Plugin\Block\LocalTasksBlock->build()
#19 [internal function]: Drupal\block\BlockViewBuilder::preRender()
#20 /var/www/html/drupal/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array()
#21 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback()
#22 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback()
#23 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
#24 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#25 /var/www/html/drupal/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render()
#26 /var/www/html/drupal/web/sites/default/files/php/twig/64b9161e11d89_page.html.twig_tLX3lPAG5dWYGtWw8b8JXWQEv/NR-hfDevAXcDXWQrSd7CyLJrHa5D1MLr60D2NyDWrbI.php(83): Drupal\Core\Template\TwigExtension->escapeFilter()
#27 /var/www/html/drupal/vendor/twig/twig/src/Template.php(405): __TwigTemplate_3e135de154d5de9377e6dc85c6165ee7->doDisplay()
#28 /var/www/html/drupal/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling()
#29 /var/www/html/drupal/vendor/twig/twig/src/Template.php(390): Twig\Template->display()
#30 /var/www/html/drupal/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render()
#31 /var/www/html/drupal/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
#32 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
#33 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#34 /var/www/html/drupal/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render()
#35 /var/www/html/drupal/web/sites/default/files/php/twig/64b9161e11d89_html.html.twig_6hWXcJ1V-Qz6Co4MgIuQvr8BF/dyAQBUrxCqdR4phYiFisBpfpGLQV7oCFByX8RVFSo-M.php(109): Drupal\Core\Template\TwigExtension->escapeFilter()
#36 /var/www/html/drupal/vendor/twig/twig/src/Template.php(405): __TwigTemplate_9820deedac8deb08ba334f2bbd93e4f8->doDisplay()
#37 /var/www/html/drupal/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling()
#38 /var/www/html/drupal/vendor/twig/twig/src/Template.php(390): Twig\Template->display()
#39 /var/www/html/drupal/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render()
#40 /var/www/html/drupal/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
#41 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
#42 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#43 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(162): Drupal\Core\Render\Renderer->render()
#44 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#45 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(163): Drupal\Core\Render\Renderer->executeInRenderContext()
#46 /var/www/html/drupal/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()
#47 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
#48 /var/www/html/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
#49 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(174): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#50 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#51 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#52 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#53 /var/www/html/drupal/web/modules/contrib/cleantalk/src/EventSubscriber/BootSubscriber.php(187): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#54 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\cleantalk\EventSubscriber\BootSubscriber->handle()
#55 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#56 /var/www/html/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#57 /var/www/html/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#58 /var/www/html/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#59 {main} - 🇨🇦Canada OMD
in tandem with that warning I'm also getting the Undefined array key "rid" warning as well:
Warning: Undefined array key "rid" in nodeaccess_node_access() (line 276 of /var/www/html/drupal/web/modules/contrib/nodeaccess/nodeaccess.module)
#0 /var/www/html/drupal/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real()
#1 /var/www/html/drupal/web/modules/contrib/nodeaccess/nodeaccess.module(276): _drupal_error_handler()
#2 [internal function]: nodeaccess_node_access()
#3 /var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(426): call_user_func_array()
#4 /var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(405): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
#5 /var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(433): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
#6 /var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php(97): Drupal\Core\Extension\ModuleHandler->invokeAll()
#7 /var/www/html/drupal/web/core/modules/node/src/NodeAccessControlHandler.php(105): Drupal\Core\Entity\EntityAccessControlHandler->access()
#8 /var/www/html/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(710): Drupal\node\NodeAccessControlHandler->access()
#9 /var/www/html/drupal/web/core/modules/node/src/Entity/Node.php(195): Drupal\Core\Entity\ContentEntityBase->access()
#10 /var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityAccessCheck.php(68): Drupal\node\Entity\Node->access()
#11 [internal function]: Drupal\Core\Entity\EntityAccessCheck->access()
#12 /var/www/html/drupal/web/core/lib/Drupal/Core/Access/AccessManager.php(160): call_user_func_array()
#13 /var/www/html/drupal/web/core/lib/Drupal/Core/Access/AccessManager.php(136): Drupal\Core\Access\AccessManager->performCheck()
#14 /var/www/html/drupal/web/core/lib/Drupal/Core/Access/AccessManager.php(93): Drupal\Core\Access\AccessManager->check()
#15 /var/www/html/drupal/web/core/lib/Drupal/Core/Menu/LocalTaskManager.php(327): Drupal\Core\Access\AccessManager->checkNamedRoute()
#16 /var/www/html/drupal/web/core/lib/Drupal/Core/Menu/LocalTaskManager.php(358): Drupal\Core\Menu\LocalTaskManager->getTasksBuild()
#17 /var/www/html/drupal/web/core/lib/Drupal/Core/Menu/Plugin/Block/LocalTasksBlock.php(95): Drupal\Core\Menu\LocalTaskManager->getLocalTasks()
#18 /var/www/html/drupal/web/core/modules/block/src/BlockViewBuilder.php(171): Drupal\Core\Menu\Plugin\Block\LocalTasksBlock->build()
#19 [internal function]: Drupal\block\BlockViewBuilder::preRender()
#20 /var/www/html/drupal/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array()
#21 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback()
#22 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback()
#23 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Render\Renderer->doRender()
#24 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#25 /var/www/html/drupal/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render()
#26 /var/www/html/drupal/web/sites/default/files/php/twig/64b918864031d_page.html.twig_tLX3lPAG5dWYGtWw8b8JXWQEv/YqFOnnW-6ePvfmiNG-F8xMd2iLQNwICeESJLeWD8ivY.php(83): Drupal\Core\Template\TwigExtension->escapeFilter()
#27 /var/www/html/drupal/vendor/twig/twig/src/Template.php(405): __TwigTemplate_3e135de154d5de9377e6dc85c6165ee7->doDisplay()
#28 /var/www/html/drupal/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling()
#29 /var/www/html/drupal/vendor/twig/twig/src/Template.php(390): Twig\Template->display()
#30 /var/www/html/drupal/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render()
#31 /var/www/html/drupal/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
#32 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
#33 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#34 /var/www/html/drupal/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render()
#35 /var/www/html/drupal/web/sites/default/files/php/twig/64b918864031d_html.html.twig_6hWXcJ1V-Qz6Co4MgIuQvr8BF/r0ykf4em7G2uZDFMxiMaTUUNpDQDzO66Fg-8QqxKr3E.php(109): Drupal\Core\Template\TwigExtension->escapeFilter()
#36 /var/www/html/drupal/vendor/twig/twig/src/Template.php(405): __TwigTemplate_9820deedac8deb08ba334f2bbd93e4f8->doDisplay()
#37 /var/www/html/drupal/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling()
#38 /var/www/html/drupal/vendor/twig/twig/src/Template.php(390): Twig\Template->display()
#39 /var/www/html/drupal/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render()
#40 /var/www/html/drupal/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
#41 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render()
#42 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender()
#43 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(162): Drupal\Core\Render\Renderer->render()
#44 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#45 /var/www/html/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(163): Drupal\Core\Render\Renderer->executeInRenderContext()
#46 /var/www/html/drupal/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()
#47 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
#48 /var/www/html/drupal/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
#49 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(174): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#50 /var/www/html/drupal/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#51 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#52 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#53 /var/www/html/drupal/web/modules/contrib/cleantalk/src/EventSubscriber/BootSubscriber.php(187): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#54 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\cleantalk\EventSubscriber\BootSubscriber->handle()
#55 /var/www/html/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#56 /var/www/html/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#57 /var/www/html/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#58 /var/www/html/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#59 {main} - 🇨🇦Canada OMD
I'm using a stable release version as well Version: 8.x-1.1 not the alpha version
- 🇨🇦Canada OMD
After investigating more, I discovered this is only happening when users are viewing older nodes that have "anonymous" as the author, presumably because the author's user account is no longer active. I can confirm that if I assign an author to the offending node, and then visit it that node, there is no further php warning messasges in the logs for this node.
- 🇨🇦Canada Nathan Tsai
So, the issue is the with 1.x branch.
And it appears that many other pages also receive the error (on the public-facing side of the website) looking at Google:
https://www.google.com/search?q=Warning%3A+Undefined+array+key+%22rid%22...
- 🇨🇦Canada Nathan Tsai
So the code in question is below.
The question is: why is
_nodeaccess_get_grants($node)
returning an empty array for some nodes?I also tried resaving the Node Access page, but it didn't resolve the issue.
/** * Implements hook_node_access(). */ function nodeaccess_node_access(NodeInterface $node, $op, $account) { $settings = \Drupal::configFactory()->get('nodeaccess.settings'); $role_map = $settings->get('role_map'); switch ($op) { case 'update': case 'delete': // If the node belongs to a deleted user. if ($account->id() == 0 && $node->getOwnerId() == 0) { // We check if the role has particular access to this node. $grants = _nodeaccess_get_grants($node); $anonymous_rid = $role_map[AccountInterface::ANONYMOUS_ROLE]; // If anonymous has rights to this node, we allow them. if (($grants['rid'][$anonymous_rid]['grant_update'] && $op == 'update') || ($grants['rid'][$anonymous_rid]['grant_delete'] && $op == 'delete')) { return AccessResult::Allowed(); } return AccessResult::forbidden(); } break; } }
- 🇫🇮Finland jviitamaki
In my use case this comes up for node types which doesn't have nodeaccess enabled.
Attached patch which at least circumvents the error message although there might be a better way to fix this. - Status changed to RTBC
over 1 year ago 9:13pm 14 December 2023 - 🇺🇸United States BenStallings
+1 for this patch. PHP doesn't like us to reference array keys that aren't defined. IMO it doesn't matter why the keys are not defined; we need to do a sanity check because PHP demands we do a sanity check.
- Assigned to darren.fisher
- 🇬🇧United Kingdom darren.fisher
I'm going to roll this in to a merge request so we can test it more thoroughly.
- 🇬🇧United Kingdom darren.fisher
Also I believe all work is now taking place on the 2.0.x branch and as it is still an issue let's start there and if needed cherry pick the change to the 1.x branch although 1.x is no longer listed as a recommended version on Drupal.org.
- Merge request !18Issue #3318190 by jungle: Use condition groups to merge the two queries in... → (Open) created by darren.fisher
- 🇬🇧United Kingdom darren.fisher
New MR to resolve this issue in 2.x. Please test thoroughly!!
https://git.drupalcode.org/project/nodeaccess/-/merge_requests/18
There are PHPUnit errors. I will try and get to these shortly!
- 🇬🇧United Kingdom darren.fisher
I think I've cracked it. Tests now pass. I must stress though I'm pretty new to the inner workings of this module so please can this be thoroughly reviewed and tested before being merged? The logic has had to be altered a fair bit from the patch for 1.x due to large changes in the module between branches!