Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Core issue #2457999: Cannot use relationship for rendered entity on Views is being considered for 8.3, but with that patch Search API views get a warning upon save:
Warning: Declaration of Drupal\search_api\Plugin\views\EntityTranslationRenderer::getLangcode(Drupal\views\ResultRow $row) should be compatible with Drupal\views\Entity\Render\TranslationLanguageRenderer::getLangcode(Drupal\views\ResultRow $row, $relationship = 'none') in require() (line 12 of modules/contrib/search_api/src/Plugin/views/EntityTranslationRenderer.php).
require('/var/www/drupalvm/drupal/docroot/modules/contrib/search_api/src/Plugin/views/EntityTranslationRenderer.php') (Line: 110)
Symfony\Component\ClassLoader\ApcClassLoader->loadClass('Drupal\search_api\Plugin\views\EntityTranslationRenderer')
spl_autoload_call('Drupal\search_api\Plugin\views\EntityTranslationRenderer') (Line: 81)
Drupal\search_api\Plugin\views\EntityFieldRenderer->getEntityTranslationRenderer() (Line: 71)
Drupal\views\Entity\Render\EntityFieldRenderer->getCacheContexts() (Line: 1010)
Drupal\views\Plugin\views\field\Field->getCacheContexts() (Line: 171)
Drupal\Core\Cache\CacheableMetadata::createFromObject(Object) (Line: 2288)
Drupal\views\Plugin\views\display\DisplayPluginBase->calculateCacheMetadata() (Line: 326)
Drupal\views\Entity\View->addCacheMetadata() (Line: 300)
Drupal\views\Entity\View->preSave(Object) (Line: 434)
Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 389)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 259)
Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object) (Line: 364)
Drupal\Core\Entity\Entity->save() (Line: 637)
Drupal\Core\Config\Entity\ConfigEntityBase->save() (Line: 986)
Drupal\views_ui\ViewUI->save() (Line: 312)
Drupal\views_ui\ViewEditForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 585)
Drupal\Core\Form\FormBuilder->processForm('view_edit_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('view_edit_form', Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'edit', Array) (Line: 226)
Drupal\views_ui\Controller\ViewsUIController->edit(Object, NULL)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comment | File | Size | Author |
---|---|---|---|
#9 | entity_field_renderers-2847956-9.patch | 676 bytes | kekkis |
#4 | entity_field_renderers-2847956-4.patch | 585 bytes | kekkis |
|
Comments
Comment #2
kekkisComment #3
kekkisSorry for messing so badly with the title :)
Comment #4
kekkisHere's the simple patch. I could really not figure out a use for the extra argument.
Comment #5
kekkisComment #6
borisson_Let's not commit this yet, until an agreement is reached in #2457999: Cannot use relationship for rendered entity on Views. Postponing this issue.
Comment #7
drunken monkeyAgree with Joris, we should wait whether this even gets added to Core.
But thanks a lot for creating this issue anyways, very helpful!
Also, luckily, since the argument is optional, this won't make any problems for people using a Core version from before this change.
Comment #8
drunken monkeyComment #9
kekkisAs we're still using this patch in one of our projects, the change made in #3083923 necessitates a reroll.