- Issue created by @Grimreaper
- 🇧🇴Bolivia manuvelasco Bolivia
Drupal: 10.2.7
Metatag: 2.0.0
I'm having the same bug after installing metatag_views with the following error message.
The website encountered an unexpected error. Try again later.Error: Attempt to assign property "type" on null in Drupal\views\ManyToOneHelper->ensureMyTable() (line 195 of core/modules/views/src/ManyToOneHelper.php).
Drupal\views\Plugin\views\argument\StringArgument->query(1) (Line: 1126)
Drupal\views\ViewExecutable->_buildArguments() (Line: 1888)
Drupal\views\ViewExecutable->buildTitle() (Line: 43)
metatag_views_get_view_tags(Object, 'page_1', Array) (Line: 87)
metatag_views_metatags_alter(Array, Array, NULL) (Line: 545)
Drupal\Core\Extension\ModuleHandler->alter('metatags', Array, Array) (Line: 497)
metatag_get_tags_from_route() (Line: 131)
metatag_page_attachments(Array) (Line: 311)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}(Object, 'metatag') (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('page_attachments', Object) (Line: 308)
Drupal\Core\Render\MainContent\HtmlRenderer->invokePageAttachmentHooks(Array) (Line: 285)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 284)
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: 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: 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: 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) - 🇮🇳India dev2.addweb
The TypeError happens because the buildTitle() method, when called, expects certain properties to be properly initialized. If the view lacks the required arguments or filters, these properties may be null or not properly set, leading to the error.
In my project I have solved this error using the following code : which presents inside metatag\metatag_views\metatag_views.module function metatag_views_get_view_tags($view, $display_id = NULL, $args = []) {
// $view->buildTitle(); $contextual_filters = !empty($view->args) ? $view->args : []; $exposed_input = !empty($view->getExposedInput()) ? $view->getExposedInput() : []; $query_options = !empty($view->query->options) ? $view->query->options : []; if(!empty($contextual_filters) || !empty($exposed_input) || !empty($query_options)) { $view->buildTitle(); }
These are some probable instances, however more checks are needed to avoid the issue