When moving a site form one environment to another have noticed that some "ghost nodes" are throwing an error in views. This prevents other processes such as indexing a site using modules like search_api_solr.
Repeatable: Sometimes??
Steps to repeat:
1. Try to index a site with a null entity object in the results.
Expected Results:
Views should detect null on prerender and render methods in views/src/Entity/Render/TranslationLanguageRenderer.php and not make method calls on non entity object
Actual Results:
Processing of results is completely halted and error is thrown:
Error: Call to undefined method stdClass::id() in Drupal\views\Entity\Render\TranslationLanguageRenderer->preRender() (line 51 of core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php)
If this is circumvented then another error is thrown in the render method on $entity_id = $row->_entity->id();
Have applied fix to make sure that the rows contain valid entity objects.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | drupal-n2869347-23.patch | 1.96 KB | damienmckenna |
| #3 | views-translation-language-renderer-2869347-2-D8.patch | 1.72 KB | richdykins |
| #2 | views-translation-language-renderer-2869347-1-D8.patch | 1.72 KB | richdykins |
Comments
Comment #2
richdykins commentedHave put checks in place to make sure that prerender and render are dealing with entities from the results.
Comment #3
richdykins commentedWhoops missed an underscore in #1.
Comment #5
lendudeWell I don't think that just silently skipping over this is the right way to go for dealing with leftover database junk (I get that it works in your use case, but we need a more generic approach I feel).
My first instinct would be to throw an exception and then whatever is doing the rendering (like search_api_solr) can deal with that how they like. But that would still stop execution on the first fail, so it doesn't really help you in this case (besides maybe giving you a more useful error to work with).
Comment #7
flocondetoileJust for reference, I met same issue
Error: Call to undefined method stdClass::id() in Drupal\views\Entity\Render\TranslationLanguageRenderer->preRender() (line 42 of core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php)But it was my fault. Using the module Views Custom Cache Tags, I forgot to invalidate the custom cache tag set on the view when a node present in the view was deleted.
May be the original issue is related too with a cache issue.
Comment #10
revija commentedFor when will this patch enter the core?
Version 8.6.7 and same problem
Thanks !!
Comment #11
szato commentedI got this error with Drupal v. 8.6.16.
1) Views Custom Cache Tags isn't installed
2) Clearing the cache doesn't solve the issue.
I didn't investigate the issue/error, but patch #2 solved the WSOD.
Comment #16
sagesolutions commentedpatch #2 solved the WSOD for me as well.
I'm not using Views Custom Cache Tags and clearing the cache didn't help. Im currently on Drupal 9.3.12.
I digged into it a bit. My view that was broken was a simple content view with a relationship to the author. The query from the view is as follows:
For some reason in my database, this query returned
nids that were no longer in the node table.I then compared
select count(*) from node_field_data;andselect count(*) from node;and they were off by a couple. Not sure how they got this way, but maybe this will help someone else.A "fix" for this is if the query joins the node table, but not sure if that's the right way to do it.
Comment #19
adevms commentedPatch #3 worked for me. Using Drupal 9.5.10
After bulk deleting nodes from the admin/content page, the db got corrupted, eg. the row from node table got deleted but in some other tables not(like node_field_data). Then on listings pages views errored in WOD with:
Error: Attempt to assign property "view" on null in Drupal\views\Entity\Render\TranslationLanguageRenderer->preRender() (line 87 of /var/www/html/web/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php)The patch from Multiple usages of FieldPluginBase::getEntity do not check for NULL, leading to WSOD helped on the admin/content page and patch #3 helped on user listing pages.
Thank you for the patch.
Comment #20
kenorb commentedSimilar error:
while using Views with CiviCRM entities.
The patch from #3 worked for Drupal 9.5.11.
Comment #22
damienmckennaHitting this on a site that's using Entity Language Fallback.
Comment #23
damienmckennaRerolled.
Comment #24
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)