Workflow issue: Error: Call to undefined method Drupal\workflow\Entity\Workflow::hasTranslation() in Drupal\domain_source\HttpKernel\DomainSourcePathProcessor->processOutbound() (line 158 of modules/contrib/domain/domain_source/src/HttpKernel/DomainSource

Created on 12 October 2023, about 1 year ago

Drupal 10.1.5

Domain 2.0.0-beta1

Expected Behavior

site should not be crashed

Actual Behavior

site crashed for workflow page.

Steps to reproduce

1. install workflow: composer require 'drupal/workflow:^1.7'
2. enable workflow, workflow access
3. Add new workflow type and get error

The website encountered an unexpected error. Please try again later.

Error: Call to undefined method Drupal\workflow\Entity\Workflow::hasTranslation() in Drupal\domain_source\HttpKernel\DomainSourcePathProcessor->processOutbound() (line 158 of modules/contrib/domain/domain_source/src/HttpKernel/DomainSourcePathProcessor.php).

Drupal\Core\PathProcessor\PathProcessorManager->processOutbound('/admin/config/workflow/workflow/content_publish', Array, Object, Object) (Line: 403)
Drupal\Core\Routing\UrlGenerator->processPath('/admin/config/workflow/workflow/content_publish', Array, Object) (Line: 305)
Drupal\Core\Routing\UrlGenerator->generateFromRoute('entity.workflow_type.edit_form', Array, Array, 1) (Line: 108)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('entity.workflow_type.edit_form', Array, Array, 1) (Line: 765)
Drupal\Core\Url->toString(1) (Line: 183)
Drupal\Core\Utility\LinkGenerator->generate(Object, Object) (Line: 95)
Drupal\Core\Render\Element\Link::preRenderLink(Array)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 797)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 386)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 474)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 77)
__TwigTemplate_1251d3c40bf9b47fa0fc0bee8e3c9500->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array, Array) (Line: 40)
Twig\TemplateWrapper->render(Array) (Line: 53)
twig_render_template('core/modules/system/templates/links.html.twig', Array) (Line: 372)
Drupal\Core\Theme\ThemeManager->render('links__dropbutton', Array) (Line: 445)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 474)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 179)
__TwigTemplate_e1e824515bbcb2480f15d6859930ddfe->doDisplay(Array, Array) (Line: 394)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367)
Twig\Template->display(Array) (Line: 379)
Twig\Template->render(Array, Array) (Line: 40)
Twig\TemplateWrapper->render(Array) (Line: 53)
twig_render_template('core/themes/claro/templates/classy/dataset/table.html.twig', Array) (Line: 372)
Drupal\Core\Theme\ThemeManager->render('table', Array) (Line: 445)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 458)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 187)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Possible solution

line number : 158

 if (
        !empty($langcode) && method_exists($entity, 'isTranslatable') && $entity->getEntityType()->isTranslatable() && $entity->hasTranslation($langcode) && $translation = $entity->getTranslation($langcode)
      ) {
        // dd($entity);
        $entity = $translation;
      }

🐛 Bug report
Status

Needs review

Version

2.0

Component

- Domain Source

Created by

🇮🇳India asif_khan

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

Comments & Activities

Production build 0.71.5 2024