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
- Standard install
- Add entity reference field to Article content type
- Create new Article and leave the reference field blank
- 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
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | 2916597-22-FAIL.patch | 5.18 KB | danflanagan8 |
| #16 | interdiff-2916597-14-16.txt | 1.38 KB | yogeshmpawar |
| #16 | 2916597-16.patch | 2.09 KB | yogeshmpawar |
| #14 | 2916597-14.patch | 2.09 KB | andrewbelcher |
| #9 | payments view.yml | 13.94 KB | honza pobořil |
Comments
Comment #2
susgo commentedComment #3
susgo commentedPatch checks for correct type so rendering works.
Comment #4
susgo commentedComment #5
cilefen commentedHi @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!
Comment #6
susgo commentedHi @cilefen:
okay, thanks!
Comment #7
seanbReroll for 8.6.x.
Comment #8
lendudeThe 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.
Comment #9
honza pobořil commentedHappens 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.
Comment #10
alex_optimHello!
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.
Comment #11
lendude#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
Comment #12
andrewbelcher commentedSo 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
The patch in #7 but didn't apply to 8.8.x, so I've re-rolled.
Comment #13
megachriz@andrewbelcher
You accidently posted an empty patch.
Comment #14
andrewbelcher commentedYes :( Let's try that again!
Comment #15
yogeshmpawarComment #16
yogeshmpawarResolved two coding standard issues & added an interdiff between two patches.
Comment #17
daffie commentedThe 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.
Comment #22
danflanagan8Here'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
BulkFormwhich 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 theBulkForm.It seems like we'll probably need to either 1) add coverage for BulkForm or 2) leave that to a separate issue.
Comment #24
larowlanMarking as a duplicate of #3007424: Multiple usages of FieldPluginBase::getEntity do not check for NULL, leading to WSOD and transferring credit over there