Problem/Motivation

After doing some updates on our homepage we used the UI to delete a node we don't require anymore.

When we go to /admin/content we get the following PHP error:

[16-oct-2017] TypeError: Argument 1 passed to Drupal\views\Plugin\views\field\EntityOperations::getEntityTranslation() must implement interface Drupal\Core\Entity\EntityInterface, null given, called in [path.to.my.site]/core/modules/views/src/Plugin/views/field/EntityOperations.php on line 111 in Drupal\views\Plugin\views\field\EntityOperations->getEntityTranslation() (line 69 of [path.to.my.site]/core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php)

So it looks like Drupal8 tries to render information about the deleted node.

Steps to Reproduce

  1. Standard install
  2. Add entity reference field to Article content type
  3. Create new Article and leave the reference field blank
  4. Create a page view of Articles as fields. Add a relationship to the content referenced by your new reference field. Add Operations links using the relationship. Save.

When you visit the view page you will get a WSOD and the error message in the IS. Something very similar happens if you add Node operations bulk form instead of the Operations links.

Proposed resolution

Ignore missing node when rendering the view.

This only stops the error message on page load, it doesn't fix the bug when deleting a node (the incomplete deleting of the node references?)

Thank you.
Susi

Comments

susgo created an issue. See original summary.

susgo’s picture

Version: 8.3.7 » 8.3.4
susgo’s picture

StatusFileSize
new1.82 KB

Patch checks for correct type so rendering works.

susgo’s picture

Assigned: susgo » Unassigned
Priority: Normal » Critical
Status: Active » Patch (to be ported)
cilefen’s picture

Component: entity system » views.module
Priority: Critical » Major
Status: Patch (to be ported) » Needs review

Hi @susgo:

Welcome! I've change some values on this issue for the following reasons: In most cases, if data is not destroyed we rate this at major priority unless there is a high incidence or because of other factors. "Needs review" is the proper status when there is a patch. "to be ported" means something different!

susgo’s picture

Hi @cilefen:

okay, thanks!

seanb’s picture

StatusFileSize
new2.02 KB

Reroll for 8.6.x.

lendude’s picture

Status: Needs review » Needs work
Issue tags: +Needs steps to reproduce, +Needs tests

The steps to reproduce are a little unclear to me. How do I get into this state?

Looking at the patch, that just looks like we are glossing over and suppressing the underlying problem. We are iterating through the views result, and one of the results/entities doesn't exist? Why is it in the result in the first place? Some steps to reproduce would help find this out I think.

honza pobořil’s picture

Version: 8.3.4 » 8.5.4
StatusFileSize
new13.94 KB

Happens when listing commerce payments with relation to orders if order is empty (payment does not have order id).

Attaching view where it happened.

If I add filter "order id is not empty" it start working.

alex_optim’s picture

Hello!
Patch #7 works well.

But to solve the problem you have to take the next steps.
So we solved this problem in the company GOLEMS G.A.B.B. for our sites and for the further work of the site do not need to patch core.

1 - Apply the patch
2 - After those put breakpoints of the debugger in lines with "continue" and "return"
3 - Then when the entity is empty, then we look id
4 - After this, you need to delete all the data with these ids from the next tables: "node", "node_revision", "node_field_data", "node_field_revision".
5 - Clear cache.

lendude’s picture

Status: Needs work » Postponed (maintainer needs more info)

#10 seems to suggest that this has nothing to do with views but with Node not cleaning up all relevant data on delete occasionally.

Still: Needs steps to reproduce

andrewbelcher’s picture

Title: TypeError when calling site admin/content after deleting a node because deleted nid is referenced » TypeError when result row doesn't have an entity
Version: 8.5.4 » 8.8.x-dev
Status: Postponed (maintainer needs more info) » Needs review
Issue tags: -Needs steps to reproduce
StatusFileSize
new0 bytes

So the initial report was related to corrupted data, but as #10 indicated, this can also occur with valid data. I suggest that is the thing the deal with here.

Steps to reproduce in core

  1. Create a view of Nodes with a non-required relationship to User
  2. Add the User operations to the view
  3. Create a node with the no author
  4. The view will error as there is no entity for the operations

The patch in #7 but didn't apply to 8.8.x, so I've re-rolled.

megachriz’s picture

@andrewbelcher
You accidently posted an empty patch.

andrewbelcher’s picture

StatusFileSize
new2.09 KB

Yes :( Let's try that again!

yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar
yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
StatusFileSize
new2.09 KB
new1.38 KB

Resolved two coding standard issues & added an interdiff between two patches.

daffie’s picture

Status: Needs review » Needs work

The fix looks good to me. Now only an automated test needs to be added. The proposed testing by @andrewbelcher in comment #12 looks like a good idea to me.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). 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.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now 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: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

danflanagan8’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new5.18 KB

Here's a fail test for the issue described in the IS. I have added steps to reproduce to the IS that essentially matches what the new test does.

This patch does not address the BulkForm which seems to be addressed in the patches even though it is not mentioned in the IS. For whatever reason I couldn't get the tests working for the BulkForm.

It seems like we'll probably need to either 1) add coverage for BulkForm or 2) leave that to a separate issue.

Status: Needs review » Needs work

The last submitted patch, 22: 2916597-22-FAIL.patch, failed testing. View results

larowlan’s picture

Status: Needs work » Closed (duplicate)
Issue tags: -Needs tests