Problem/Motivation

Vyskytla sa chyba AJAX HTTP.
HTTP Result Code: 500
Debugging information follows.
Path: /admin/structure/views/view/produkty/preview/page_1
Stavový text: error
ResponseText: The website encountered an unexpected error. Try again later.Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of core/lib/Drupal/Core/Entity/EntityTypeManager.php). Drupal\views\Plugin\views\field\BulkForm->getEntityTranslationRenderer() (Line: 98)
Drupal\views\Plugin\views\field\BulkForm->getEntityTranslationByRelationship(Object, Object) (Line: 144)
Drupal\search_api\Plugin\views\field\SearchApiBulkForm->viewsForm(Array, Object) (Line: 111)
Drupal\views\Form\ViewsFormMainForm->buildForm(Array, Object, Object, Array) (Line: 172)
Drupal\views\Form\ViewsForm->buildForm(Array, Object, Object, Array)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('views_form_produkty_page_1', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 224)
Drupal\Core\Form\FormBuilder->getForm(Object, Object, Array) (Line: 2262)
Drupal\views\Plugin\views\display\DisplayPluginBase->elementPreRender(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: 493)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 493)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 493)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 240)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 153)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 154)
Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 66)
Drupal\Core\Render\MainContent\AjaxRenderer->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)
"

Steps to reproduce

1. add multiple languages to the website
2. enable translation for content types
3. add search API indexing contents all languages
4. try to build a Search API based view that lists content in the current language and try to add the Bulk operations field

Proposed resolution

Remaining tasks

Issue fork search_api-3490247

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kaszarobert created an issue. See original summary.

kaszarobert’s picture

Here's a quick fix we made to continue rendering when the langcode could not be detected for some reason. Maybe there's a better way to propagate this but I didn't have the time to dive deep into it.

drunken monkey made their first commit to this issue’s fork.

drunken monkey’s picture

Issue tags: +Needs tests
StatusFileSize
new6.69 KB

Thanks for reporting this problem!
I could indeed reproduce it right away: If there are translations in the view (maybe even just if the site is multilingual) there is a fatal error.
Looking at the code, I actually think we don’t even need getEntityTranslationByRelationship(). In our case, the result entities should all already have the correct language.

I created an MR with that approach, please try it out and tell me if it resolves the problem for you!

I also tried amending SearchApiBulkFormTest to catch this problem in the future, just by adding one translation to the test entities. However, for some reason which I couldn’t figure out for the life of me the translation I added just didn’t save properly. See the attached patch – maybe you (or someone else?) are able to make it work?
(For me, this fails at the last line tagged with # Temporary debug code. – the translation is just not there anymore after reloading the entity.)
In any case I think we should have a regression test for this before merging.

drunken monkey’s picture

Status: Needs review » Needs work

Would be great to get a) feedback and b) help on that test. It has to be something stupid, probably because I’m unused to working with translations – maybe someone more experienced there can quickly spot my mistake?

huzooka’s picture

Assigned: Unassigned » huzooka

I need this to be fixed in my project.

huzooka’s picture

I pushed my hotfix to a new branch because the preexisting looks like a hotfix (maybe I just don't understand it) and I don't want to ruin it.
Leaving tags and status because we still need tests; but first it would be nice to see what the test coverage reveals.

huzooka’s picture

Assigned: huzooka » Unassigned

I won't work on this in the next couple of hours for sure.

huzooka’s picture

Assigned: Unassigned » huzooka

I try to build test coverage.

huzooka’s picture

@drunken monkey
I've found the problem with your wip test coverage: the EntityTest entity type is not translatable. We devs are so used to the fact that entities are generally translatable that we take it for granted. I think I noticed it just because I've run into it few weeks ago.

huzooka’s picture

Let's see what fails on CI.

huzooka’s picture

We have test coverage, and the issue seems to be fixed.

Asking for review.

huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs tests

huzooka changed the visibility of the branch 3490247-error-vbo-translated-entities to hidden.

alorenc’s picture

The patch resolves my issue, but I don’t feel I’m the best person to perform a code review

drunken monkey’s picture

Status: Needs review » Fixed

@huzooka: Brilliant, thank you so much!
Just adjusted the code style slightly, otherwise your MR looked very good. And you’re right, the other MR seems like it was just a band-aid, not a proper fix.
Since pipelines still passed I merged this now.
Thanks again!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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