TypeError: Argument 1 passed to Drupal\flag\TwigExtension\FlagCount::count() must implement interface

Created on 28 August 2020, over 4 years ago
Updated 5 May 2023, almost 2 years ago

Problem/Motivation

Add a FlagCount to a content type. Let registered users to flag. Let anonymous users see the flag but not to click the flag.

Steps to reproduce

Flag 8.x-4.0-beta2+1-dev (2020-Aug-07) + drupal 8.9.3 + PHP 7.2|| PHP 7.4
Then an anonymous user tries to access the node I get
"The website encountered an unexpected error. Please try again later."
and

TypeError: Argument 1 passed to Drupal\flag\TwigExtension\FlagCount::count() must implement interface Drupal\flag\FlagInterface, null given, called in /www/wwwroot/dev8.ga/sites/default/files/php/twig/5f4947d92de77_flag-count.html.twig_marq4nqB0QyoHeOxr2Cg4XNPZ/cvWi1ACl-5IbmNbpT6loWw42kfyqx_vkbkHIBwXWpmg.php on line 83 in Drupal\flag\TwigExtension\FlagCount->count() (line 64 of /www/wwwroot/dev8.ga/modules/flag/src/TwigExtension/FlagCount.php)
#0 /www/wwwroot/dev8.ga/sites/default/files/php/twig/5f4947d92de77_flag-count.html.twig_marq4nqB0QyoHeOxr2Cg4XNPZ/cvWi1ACl-5IbmNbpT6loWw42kfyqx_vkbkHIBwXWpmg.php(83): Drupal\flag\TwigExtension\FlagCount->count()
#1 /www/wwwroot/dev8.ga/vendor/twig/twig/src/Template.php(455): __TwigTemplate_e5d8f5aceed27648c4ea77556ac7bd36a75140337c1f058d13cfd9ccf5ecd2dd->doDisplay()
#2 /www/wwwroot/dev8.ga/vendor/twig/twig/src/Template.php(422): Twig\Template->displayWithErrorHandling()
#3 /www/wwwroot/dev8.ga/vendor/twig/twig/src/Template.php(434): Twig\Template->display()
#4 /www/wwwroot/dev8.ga/core/themes/engines/twig/twig.engine(64): Twig\Template->render()
#5 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template()
#6 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(431): Drupal\Core\Theme\ThemeManager->render()
#7 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(200): Drupal\Core\Render\Renderer->doRender()
#8 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(156): Drupal\Core\Render\Renderer->render()
#9 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
#10 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(157): Drupal\Core\Render\Renderer->executeInRenderContext()
#11 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(171): Drupal\Core\Render\Renderer->renderPlain()
#12 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(658): Drupal\Core\Render\Renderer->renderPlaceholder()
#13 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(543): Drupal\Core\Render\Renderer->replacePlaceholders()
#14 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(200): Drupal\Core\Render\Renderer->doRender()
#15 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(144): Drupal\Core\Render\Renderer->render()
#16 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
#17 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/Renderer.php(145): Drupal\Core\Render\Renderer->executeInRenderContext()
#18 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(282): Drupal\Core\Render\Renderer->renderRoot()
#19 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php(131): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->renderPlaceholders()
#20 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/EventSubscriber/HtmlResponseSubscriber.php(45): Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments()
#21 [internal function]: Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond()
#22 /www/wwwroot/dev8.ga/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
#23 /www/wwwroot/dev8.ga/vendor/symfony/http-kernel/HttpKernel.php(191): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#24 /www/wwwroot/dev8.ga/vendor/symfony/http-kernel/HttpKernel.php(130): Symfony\Component\HttpKernel\HttpKernel->filterResponse()
#25 /www/wwwroot/dev8.ga/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#26 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle()
#27 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle()
#28 /www/wwwroot/dev8.ga/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#29 /www/wwwroot/dev8.ga/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch()
#30 /www/wwwroot/dev8.ga/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup()
#31 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle()
#32 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#33 /www/wwwroot/dev8.ga/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#34 /www/wwwroot/dev8.ga/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle()
#35 /www/wwwroot/dev8.ga/index.php(19): Drupal\Core\DrupalKernel->handle()
#36 {main}

permissions are like this:
https://prnt.sc/u7njgh

๐Ÿ› Bug report
Status

Needs work

Version

4.0

Component

Miscellaneous

Created by

๐Ÿ‡ท๐Ÿ‡ดRomania idflorin

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024