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.

Comments

richdykins created an issue. See original summary.

richdykins’s picture

Status: Active » Needs review
StatusFileSize
new1.72 KB

Have put checks in place to make sure that prerender and render are dealing with entities from the results.

richdykins’s picture

Whoops missed an underscore in #1.

The last submitted patch, 2: views-translation-language-renderer-2869347-1-D8.patch, failed testing.

lendude’s picture

Status: Needs review » Needs work
Issue tags: -views translation render +Needs tests, +Needs steps to reproduce
+++ b/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php
@@ -56,9 +59,12 @@ public function preRender(array $result) {
+    return '';

Well 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).

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

flocondetoile’s picture

Just 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.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

revija’s picture

For when will this patch enter the core?
Version 8.6.7 and same problem

Thanks !!

szato’s picture

I 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.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
sagesolutions’s picture

patch #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:

SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid, users_field_data_node_field_data.uid AS users_field_data_node_field_data_uid
FROM node_field_data node_field_data
INNER JOIN users_field_data users_field_data_node_field_data ON node_field_data.uid = users_field_data_node_field_data.uid
WHERE ((users_field_data_node_field_data.uid = '208338')) AND ((node_field_data.status = '1') AND (node_field_data.type IN ('classified')))
ORDER BY node_field_data_created DESC
LIMIT 20 OFFSET 0

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; and select 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.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

adevms’s picture

Patch #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.

kenorb’s picture

Similar error:

PHP message: Error: Attempt to assign property "view" on null in /var/www/html/web/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php on line 87 #0 /var/www/html/web/core/modules/views/src/Plugin/views/row/EntityRow.php(221): Drupal\views\Entity\Render\TranslationLanguageRenderer->preRender(Array)
#1 /var/www/html/web/core/modules/views/src/Plugin/views/style/StylePluginBase.php(444): Drupal\views\Plugin\views\row\EntityRow->preRender(Array)
#2 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1513): Drupal\views\Plugin\views\style\StylePluginBase->preRender(Array)
#3 /var/www/html/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(2459): Drupal\views\ViewExecutable->render()
#4 /var/www/html/web/core/modules/views/src/ViewExecutable.php(1667): Drupal\views\Plugin\views\display\DisplayPluginBase->preview()
#5 /var/www/html/web/core/modules/views_ui/src/ViewUI.php(611): Drupal\views\ViewExecutable->preview('page_1', Array)

while using Views with CiviCRM entities.

The patch from #3 worked for Drupal 9.5.11.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

damienmckenna’s picture

Hitting this on a site that's using Entity Language Fallback.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new1.96 KB

Rerolled.

needs-review-queue-bot’s picture

Status: Needs review » Needs work

The 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.)

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.