- 🇩🇪Germany mxh Offenburg
Thanks for the report. This is a bug within ECA, because it implements
hook_entity_view_mode_alter
and its hook documentation required a variable without type declaration (also in Drupal 11): https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...
.. whereas the hook implementation of ECA adds a string type declaration to the argument:<?php /** * Implements hook_entity_view_mode_alter(). */ function eca_content_entity_view_mode_alter(string &$view_mode, EntityInterface $entity): void { _eca_content_hook_handler()->viewModeAlter($view_mode, $entity); } ?>
The fix would be to make the arguments compatible as per hook documentation (i.e. no strict type declaration in the function arguments).
This is probably also a problem for other hook implementations of ECA, but don't know where all of that was made. - Status changed to Postponed: needs info
about 2 months ago 4:00pm 23 July 2024 - 🇩🇪Germany jurgenhaas Gottmadingen
I tend to disagree on this one. The hook declaration is not an interface, it's just a documentation file for the API at https://api.drupal.org
The
hook_entity_view_mode_alter
doesn't declare the argument type in the method itself, but it clearly states in the doc block, that this variable needs to be a string, not NULL. So, if this hook is being called with a NULL value, that's more likely to be an issue of that calling instance.Unfortunately, we don't know what's calling this hook in this context. @pearls can you please provide the full stack trace? I've looked through the code of ajax_comments but couldn't find where they call
entity_view_mode_alter
. So, we can only find out with the stack trace, what's causing this issue. I really don't know what the problem is. I just wanted to share the dbLog message report with you.
They stopped to work together after D.10.3. Ajax comments also breaks message subscribe example module.
To use Eca, there was no choice but to uninstall the ajax_comments module.
I gave up using the ajax_comments module for this project.
I did not encounter the ECA message mentioned at any other point. If it comes out again in a different way, I will share it.
Here are the previous logs.
Thanks, again.TypeError: eca_content_entity_view_mode_alter(): Argument #1 ($view_mode) must be of type string, null given, called in /var/www/html/test/web/core/lib/Drupal/Core/Extension/ModuleHandler.php on line 552 in eca_content_entity_view_mode_alter() (line 173 of /var/www/html/test/web/modules/contrib/eca/modules/content/eca_content.module).
#0 /var/www/html/test/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(552): eca_content_entity_view_mode_alter() #1 /var/www/html/test/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(180): Drupal\Core\Extension\ModuleHandler->alter() #2 /var/www/html/test/web/core/modules/node/src/NodeViewBuilder.php(61): Drupal\Core\Entity\EntityViewBuilder->getBuildDefaults() #3 /var/www/html/test/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(157): Drupal\node\NodeViewBuilder->getBuildDefaults() #4 /var/www/html/test/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(123): Drupal\Core\Entity\EntityViewBuilder->viewMultiple() #5 /var/www/html/test/web/modules/contrib/ajax_comments/src/Utility.php(101): Drupal\Core\Entity\EntityViewBuilder->view() #6 /var/www/html/test/web/modules/contrib/ajax_comments/ajax_comments.module(104): Drupal\ajax_comments\Utility::getWrapperIdFromEntity() #7 /var/www/html/test/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(552): ajax_comments_comment_links_alter() #8 /var/www/html/test/web/core/modules/comment/src/CommentLazyBuilders.php(150): Drupal\Core\Extension\ModuleHandler->alter() #9 [internal function]: Drupal\comment\CommentLazyBuilders->renderLinks() #10 /var/www/html/test/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(113): call_user_func_array() #11 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(870): Drupal\Core\Render\Renderer->doTrustedCallback() #12 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(411): Drupal\Core\Render\Renderer->doCallback() #13 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender() #14 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(165): Drupal\Core\Render\Renderer->render() #15 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() #16 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(164): Drupal\Core\Render\Renderer->executeInRenderContext() #17 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(191): Drupal\Core\Render\Renderer->renderInIsolation() #18 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(723): Drupal\Core\Render\Renderer->doRenderPlaceholder() #19 [internal function]: Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() #20 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(731): Fiber->start() #21 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(608): Drupal\Core\Render\Renderer->replacePlaceholders() #22 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender() #23 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(153): Drupal\Core\Render\Renderer->render() #24 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() #25 /var/www/html/test/web/core/lib/Drupal/Core/Render/Renderer.php(152): Drupal\Core\Render\Renderer->executeInRenderContext() #26 /var/www/html/test/web/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(288): Drupal\Core\Render\Renderer->renderRoot() #27 /var/www/html/test/web/core/modules/big_pipe/src/Render/BigPipeResponseAttachmentsProcessor.php(74): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->renderPlaceholders() #28 /var/www/html/test/web/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php(45): Drupal\big_pipe\Render\BigPipeResponseAttachmentsProcessor->processAttachments() #29 [internal function]: Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond() #30 /var/www/html/test/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func() #31 /var/www/html/test/vendor/symfony/http-kernel/HttpKernel.php(214): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() #32 /var/www/html/test/vendor/symfony/http-kernel/HttpKernel.php(202): Symfony\Component\HttpKernel\HttpKernel->filterResponse() #33 /var/www/html/test/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #34 /var/www/html/test/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle() #35 /var/www/html/test/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #36 /var/www/html/test/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #37 /var/www/html/test/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle() #38 /var/www/html/test/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\big_pipe\StackMiddleware\ContentLength->handle() #39 /var/www/html/test/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch() #40 /var/www/html/test/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup() #41 /var/www/html/test/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle() #42 /var/www/html/test/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #43 /var/www/html/test/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #44 /var/www/html/test/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle() #45 /var/www/html/test/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle() #46 /var/www/html/test/web/index.php(19): Drupal\Core\DrupalKernel->handle()
- 🇩🇪Germany jurgenhaas Gottmadingen
This is very helpful, thank @pearls If you don't mind, I'd like to follow up on this a bit further because it may identify some interesting gotchas.
The stack trace you posted makes perfect sense. All the references and line numbers are accurate, except for one:
#5 /var/www/html/test/web/modules/contrib/ajax_comments/src/Utility.php(101): Drupal\Core\Entity\EntityViewBuilder->view()
The call to
EntityViewBuilder->view()
is actually on line 96, not 101. Unless you're not using the latest (beta5) release. In beta4 it used to be line 100. Closer, but still not the same. Is it possible that you have modified the file/src/Utility.php
in the ajax_comment module, either manually or with a patch? Because in the original state of the file, there is a view mode provided as a string and never a NULL, which is later passed on to ECA by mistake.If you're certain, that the file has not been modified locally, then there is one other option how that could happen: another contrib module implements the hook
entity_view_mode_alter
and modifies the given value from'full'
toNULL
. If you have a chance, it would be very interesting to know if and where the string_entity_view_mode_alter
can be found in the whole code base of your Drupal installation. - Status changed to Fixed
12 days ago 7:01am 27 August 2024