In some cases, the entity type of the activity message is empty, therefore, the site encounters the following error:

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Component\Plugin\Exception\PluginNotFoundException</em>: The &quot;&quot; entity type does not exist. in <em class="placeholder">Drupal\Core\Entity\EntityTypeManager-&gt;getDefinition()</em> (line <em class="placeholder">133</em> of <em class="placeholder">core/lib/Drupal/Core/Entity/EntityTypeManager.php</em>). <pre class="backtrace">Drupal\Core\Entity\EntityTypeManager-&gt;getHandler(NULL, &#039;storage&#039;) (Line: 169)
Drupal\Core\Entity\EntityTypeManager-&gt;getStorage(NULL) (Line: 76)
activity_logger_tokens(&#039;message&#039;, Array, Array, Array, Object)
call_user_func_array(&#039;activity_logger_tokens&#039;, Array) (Line: 402)
Drupal\Core\Extension\ModuleHandler-&gt;invokeAll(&#039;tokens&#039;, Array) (Line: 304)
Drupal\Core\Utility\Token-&gt;generate(&#039;message&#039;, Array, Array, Array, Object) (Line: 196)
Drupal\Core\Utility\Token-&gt;replace(&#039;&lt;a href=&quot;absolute]&quot;&gt;[message:author:display-name]&lt;/a&gt; posted on your &lt;a href=&quot;recipient-user-url]&quot;&gt;profile&lt;/a&gt;
&#039;, Array, Array) (Line: 490)
Drupal\activity_creator\ActivityFactory-&gt;processTokens(Array, , Object) (Line: 415)
Drupal\activity_creator\ActivityFactory-&gt;getMessageText(Object) (Line: 217)
activity_creator_entity_view(Array, Object, Object, &#039;default&#039;)
call_user_func_array(&#039;activity_creator_entity_view&#039;, Array) (Line: 402)
Drupal\Core\Extension\ModuleHandler-&gt;invokeAll(&#039;entity_view&#039;, Array) (Line: 270)
Drupal\Core\Entity\EntityViewBuilder-&gt;buildMultiple(Array) (Line: 220)
Drupal\Core\Entity\EntityViewBuilder-&gt;build(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer-&gt;doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension-&gt;escapeFilter(Object, Array, &#039;html&#039;, NULL, 1) (Line: 56)
__TwigTemplate_f50f8172a84c7198d2cc4da8618d1c40313d6a12a9f7353b289fc5a248ba998e-&gt;doDisplay(Array, Array) (Line: 432)
Twig_Template-&gt;displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template-&gt;display(Array) (Line: 411)
Twig_Template-&gt;render(Array) (Line: 64)
twig_render_template(&#039;profiles/contrib/social/themes/socialbase/templates/views/views-view-unformatted.html.twig&#039;, Array) (Line: 384)
Drupal\Core\Theme\ThemeManager-&gt;render(&#039;views_view_unformatted&#039;, Array) (Line: 437)
Drupal\Core\Render\Renderer-&gt;doRender(Array) (Line: 450)
Drupal\Core\Render\Renderer-&gt;doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension-&gt;escapeFilter(Object, Array, &#039;html&#039;, NULL, 1) (Line: 93)
__TwigTemplate_81799818edf8f3995b9f28bc9bde5a2629f5740e88618bc0f07f00a1826bbf25-&gt;doDisplay(Array, Array) (Line: 432)
Twig_Template-&gt;displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template-&gt;display(Array) (Line: 411)
Twig_Template-&gt;render(Array) (Line: 64)
twig_render_template(&#039;themes/custom/awa2el/templates/views/views-view--stream.html.twig&#039;, Array) (Line: 384)
Drupal\Core\Theme\ThemeManager-&gt;render(&#039;views_view&#039;, Array) (Line: 437)
Drupal\Core\Render\Renderer-&gt;doRender(Array) (Line: 450)
Drupal\Core\Render\Renderer-&gt;doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension-&gt;escapeFilter(Object, Array, &#039;html&#039;, NULL, 1) (Line: 114)
__TwigTemplate_e4331f4af53638808a6cce2f816bf8c59ca552219a226bdb53e6a9c71ed9330e-&gt;block_content(Array, Array) (Line: 215)
Twig_Template-&gt;displayBlock(&#039;content&#039;, Array, Array) (Line: 96)
__TwigTemplate_e4331f4af53638808a6cce2f816bf8c59ca552219a226bdb53e6a9c71ed9330e-&gt;doDisplay(Array, Array) (Line: 432)
Twig_Template-&gt;displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template-&gt;display(Array) (Line: 411)
Twig_Template-&gt;render(Array) (Line: 64)
twig_render_template(&#039;profiles/contrib/social/themes/socialbase/templates/block/block.html.twig&#039;, Array) (Line: 384)
Drupal\Core\Theme\ThemeManager-&gt;render(&#039;block&#039;, Array) (Line: 437)
Drupal\Core\Render\Renderer-&gt;doRender(Array) (Line: 450)
Drupal\Core\Render\Renderer-&gt;doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension-&gt;escapeFilter(Object, Array, &#039;html&#039;, NULL, 1) (Line: 231)
__TwigTemplate_c5a891183f19395669fcd0128629ada924d28a7885bd2b58eb670ee013cdf5b7-&gt;block_content(Array, Array) (Line: 215)
Twig_Template-&gt;displayBlock(&#039;content&#039;, Array, Array) (Line: 181)
__TwigTemplate_c5a891183f19395669fcd0128629ada924d28a7885bd2b58eb670ee013cdf5b7-&gt;block_main(Array, Array) (Line: 215)
Twig_Template-&gt;displayBlock(&#039;main&#039;, Array, Array) (Line: 89)
__TwigTemplate_c5a891183f19395669fcd0128629ada924d28a7885bd2b58eb670ee013cdf5b7-&gt;doDisplay(Array, Array) (Line: 432)
Twig_Template-&gt;displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template-&gt;display(Array) (Line: 411)
Twig_Template-&gt;render(Array) (Line: 64)
twig_render_template(&#039;themes/custom/awa2el/templates/layout/page.html.twig&#039;, Array) (Line: 384)
Drupal\Core\Theme\ThemeManager-&gt;render(&#039;page&#039;, Array) (Line: 437)
Drupal\Core\Render\Renderer-&gt;doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension-&gt;escapeFilter(Object, Array, &#039;html&#039;, NULL, 1) (Line: 127)
__TwigTemplate_ec32923cff9fd8e8aecae678d5e9e0d127ece9d8b39eca277480833660e1f435-&gt;doDisplay(Array, Array) (Line: 432)
Twig_Template-&gt;displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template-&gt;display(Array) (Line: 411)
Twig_Template-&gt;render(Array) (Line: 64)
twig_render_template(&#039;themes/custom/awa2el/templates/system/html.html.twig&#039;, Array) (Line: 384)
Drupal\Core\Theme\ThemeManager-&gt;render(&#039;html&#039;, Array) (Line: 437)
Drupal\Core\Render\Renderer-&gt;doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array) (Line: 147)
Drupal\Core\Render\MainContent\HtmlRenderer-&gt;Drupal\Core\Render\MainContent\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 148)
Drupal\Core\Render\MainContent\HtmlRenderer-&gt;renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber-&gt;onViewRenderArray(Object, &#039;kernel.view&#039;, Object)
call_user_func(Array, Object, &#039;kernel.view&#039;, Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher-&gt;dispatch(&#039;kernel.view&#039;, Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 666)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)

Comments

Omar Alahmed created an issue. See original summary.

omar alahmed’s picture

The following patch may not be the perfect solution, however, it will stop the error and make the site back.

omar alahmed’s picture

StatusFileSize
new2.18 KB

Re-roll the patch to be applied from the Open Social profile directory.

jaapjan’s picture

Thanks for the patch. It does make sense to make the code a bit more defensive. However I'm curious what the steps are to reproduce this scenario?

jaapjan’s picture

Status: Active » Needs review
jochemvn’s picture

I've encountered the same issue, but I'm not sure how it happened.

Problem is that some messages don’t have a related entity, which is weird (and shouldn’t be possible). Since the update where we worked on translations (not really sure about which version). We don’t display the output text that’s generated in the activity entity (from the message) anymore. On the stream pages the message template tokens are being de-tokenized on the fly now, this is why this bug comes to light now.

I’m also very curious how this happened. Do you have any idea @omar?

Because the data is also stored in the activity it should be possible to load it from there and put it back.

omar alahmed’s picture

Actually, I don't know the root cause of the error, but in my project, I have extra entities than the Open Social default, like media and ad, I think this may be a reason.

jaapjan’s picture

jaapjan’s picture

Status: Needs review » Fixed

Merged, thank you for the patch.

  • d8c0ef2 committed on 8.x-3.x
    Issue #2993086 by Omar Alahmed: Message related object entity type is...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.