- Issue created by @slideaway
- Status changed to Closed: works as designed
9 months ago 10:10am 24 February 2024 - 🇧🇪Belgium swentel
You need to clear the caches, e.g. drush cr
See 🐛 Error: Class "Drupal\ds\ContextProvider\DsBlockFieldEntityContext" not found Closed: works as designed as well. - 🇨🇦Canada slideaway
I've run drush cr and drush updb about 1000 times trying to fix this. That is not the issue.
- 🇧🇪Belgium swentel
Are you able to check if ds.services.yml still contains 'ds.ds_block_field_entity_context' ? If so, than something went wrong with the update in that installation, as the corresponding class 'DsBlockFieldEntityContext' has been removed. Those lines shouldn't be there in the services file.
- 🇨🇦Canada slideaway
I found that @ds.ds_block_field_entity_context:block_content was being referenced in a view config file that wasn't even really being used, but it caused my whole site to lock up. Not sure if that's a bug onto itself, but it seemed to be rather unforgiving as far an error.
In the end the reason I wasn't finding 'ds.ds_block_field_entity_context' when I searched my codebase was because the /config files were in my gitignore and I didn't really Sublime Text was excluding search results based on my gitignore. Found it using the macOS Spotlight search instead. Thanks for the help!
- 🇧🇪Belgium swentel
Hmm, interesting that this is stored somewhere, didn't expect that. But good to know!
- 🇭🇺Hungary janoka
Hi, I also find the same error, please see:
The website encountered an unexpected error. Try again later. Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "ds.ds_block_field_entity_context". in Drupal\Component\DependencyInjection\Container->get() (line 157 of core/lib/Drupal/Component/DependencyInjection/Container.php). Drupal\Core\Plugin\Context\LazyContextRepository->getRuntimeContexts(Array) (Line: 87) Drupal\ds\Plugin\DsField\BlockBase->build() (Line: 370) ds_entity_view_alter(Array, Object, Object) (Line: 545) Drupal\Core\Extension\ModuleHandler->alter('node_view', Array, Object, Object) (Line: 304) Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 238) Drupal\Core\Entity\EntityViewBuilder->build(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: 859) Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 421) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240) Drupal\Core\Render\Renderer->render(Array) (Line: 475) Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 61) __TwigTemplate_949414fb0eb3735d040b185bffb430a7->doDisplay(Array, Array) (Line: 394) Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367) Twig\Template->display(Array) (Line: 379) Twig\Template->render(Array) (Line: 38) Twig\TemplateWrapper->render(Array) (Line: 39) twig_render_template('themes/contrib/bootstrap_barrio/templates/views/views-view-unformatted.html.twig', Array) (Line: 348) Drupal\Core\Theme\ThemeManager->render('views_view_unformatted', Array) (Line: 480) Drupal\Core\Render\Renderer->doRender(Array) (Line: 493) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240) Drupal\Core\Render\Renderer->render(Array) (Line: 475) Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 110) __TwigTemplate_0289e490f1fe4985ae939abb483d2d7f->doDisplay(Array, Array) (Line: 394) Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367) Twig\Template->display(Array) (Line: 379) Twig\Template->render(Array) (Line: 38) Twig\TemplateWrapper->render(Array) (Line: 39) twig_render_template('themes/contrib/bootstrap_barrio/templates/views/views-view.html.twig', Array) (Line: 348) Drupal\Core\Theme\ThemeManager->render('views_view', Array) (Line: 480) Drupal\Core\Render\Renderer->doRender(Array) (Line: 493) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240) Drupal\Core\Render\Renderer->render(Array) (Line: 475) Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 85) __TwigTemplate_a8062bbb8a384752e478762407d5ac78->block_content(Array, Array) (Line: 171) Twig\Template->displayBlock('content', Array, Array) (Line: 68) __TwigTemplate_a8062bbb8a384752e478762407d5ac78->doDisplay(Array, Array) (Line: 394) Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367) Twig\Template->display(Array) (Line: 379) Twig\Template->render(Array) (Line: 38) Twig\TemplateWrapper->render(Array) (Line: 39) twig_render_template('themes/contrib/bootstrap_barrio/templates/block/block.html.twig', Array) (Line: 348) Drupal\Core\Theme\ThemeManager->render('block', Array) (Line: 480) Drupal\Core\Render\Renderer->doRender(Array) (Line: 493) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240) Drupal\Core\Render\Renderer->render(Array) (Line: 475) Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 281) __TwigTemplate_d445fdf1bf77c837b69a65779fd490dc->block_content(Array, Array) (Line: 171) Twig\Template->displayBlock('content', Array, Array) (Line: 84) __TwigTemplate_d445fdf1bf77c837b69a65779fd490dc->doDisplay(Array, Array) (Line: 394) Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367) Twig\Template->display(Array) (Line: 379) Twig\Template->render(Array) (Line: 38) Twig\TemplateWrapper->render(Array) (Line: 39) twig_render_template('themes/custom/muzej/templates/layout/page.html.twig', Array) (Line: 348) Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 480) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240) Drupal\Core\Render\Renderer->render(Array) (Line: 475) Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 84) __TwigTemplate_fa2e9af442c17f5931b4d2d25cf2f723->doDisplay(Array, Array) (Line: 394) Twig\Template->displayWithErrorHandling(Array, Array) (Line: 367) Twig\Template->display(Array) (Line: 379) Twig\Template->render(Array) (Line: 38) Twig\TemplateWrapper->render(Array) (Line: 39) twig_render_template('themes/contrib/bootstrap_barrio/templates/layout/html.html.twig', Array) (Line: 348) Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 480) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240) Drupal\Core\Render\Renderer->render(Array) (Line: 158) Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 153) 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: 186) 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: 28) Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32) Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 270) Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 137) Drupal\shield\ShieldMiddleware->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: 36) Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Background:
I was migrating the website from Drupal 9 to 10.
And the previous DS module was 8.x-3.15.I have DS fields in the project, like the config (
config/sync/ds.field.buszmegallo_helyszinekkel.yml
):id: buszmegallo_helyszinekkel label: 'Bus stops' ui_limit: 'bus_line|*' type: block type_label: 'Block field' entities: taxonomy_term: taxonomy_term properties: block: 'views_block:buszmegallok_es_helyszinek-block_1' use_block_title: false add_block_wrappers: false config: id: 'views_block:buszmegallok_es_helyszinek-block_1' label: '' label_display: visible provider: views context_mapping: field_bus_stop_line_target_id: '@ds.ds_block_field_entity_context:taxonomy_term' views_label: '' items_per_page: none
Of course, this may not be relevant.
I use the latest stable version,
8.x-3.19
.Do you have any idea?
- 🇭🇺Hungary zserno
I faced the same issue as #7. In my case I had custom DS block fields that were holding views blocks. These views all had contextual filters.
In D9, such DS fields were created with @ds.ds_block_field_entity_context:[entity] in their context mapping. As per #4, this context was removed from DS, so a manual resave was necessary on these DS fields' Configure block form (located at /admin/structure/ds/fields/manage_block/[ds_field_name]/block_config).
To summarize, the following steps fixed the exception for me:
- Search for the string "ds_block_field_entity_context" among the site's config files:
grep -nri ds_block_field_entity_context ./config/
- For each ds.field.[ds_field_name].yml in the grep result, submit the settings form at /admin/structure/ds/fields/manage_block/[ds_field_name]/block_config
Diff after executing above steps and a fresh config export:
context_mapping: - nid: '@ds.ds_block_field_entity_context:node' + nid: '@node.node_route_context:node'
- Search for the string "ds_block_field_entity_context" among the site's config files: