Problem/Motivation

After updating my site to Drupal 9.2.7 and Field inheritance 2.0.x-dev I got a fatal error on all views pages using inherited fields.
Error: Call to a member function getType() on null in Drupal\views\Plugin\views\field\EntityField->defineOptions() (line 378 of core/modules/views/src/Plugin/views/field/EntityField.php).

Proposed resolution

Using a newer version of views computed field patch resolves this issue for me.

I used the changes of core/modules/views/src/Plugin/views/field/EntityField.php from https://www.drupal.org/files/issues/2021-01-30/drupal-computed_bundle_ba... instead of https://www.drupal.org/files/issues/2019-10-20/2981047-fix-only-44.patch

The difference is the iteration over the bundles I think. Is it possible to change the patch in composer.json to either this patch version or one without the tests that only fixes the error in EntityField.php?

Comments

Daniel_Rempe created an issue. See original summary.

owenbush’s picture

Ahhh. I had completely forgotten I included that patch as part of the composer.json fike. I'll try and get that updated to a new one. I'm still pushing that issue trying to get it to a place where it is passing tests (which keep changing due to other issues).

owenbush’s picture

Status: Active » Needs work
Issue tags: +rc eligible

  • owenbush committed 3670d0b on 2.0.x
    Issue #3241194 by owenbush: Call to a member function getType() on views...

  • owenbush committed d9c6eaf on 8.x-1.x
    Issue #3241194 by owenbush: Call to a member function getType() on views...
owenbush’s picture

Status: Needs work » Postponed

I've decided the best approach at this point is to remove the patch defined in composer.json because the issue is keeping up with the latest 9.3.x core so there's no guarantee the patch will apply to any given codebase. It makes more sense to remove it at this time and let people figure out which patches work and which don't.

https://www.drupal.org/files/issues/2021-01-30/drupal-computed_bundle_ba...
is the last working patch, and now all the code is in a MR:
https://git.drupalcode.org/project/drupal/-/merge_requests/1019/diffs.diff

I'm still waiting on #3116481: Convert EntityViewsDataTest from a unit test to a kernel test to be merged before I can update #2981047: Allow adding computed bundle fields in Views to use the new kernel tests. So we're blocked. I'll mark this as postponed for now.

tonytheferg’s picture

Posted a patch for 10.2.6 for anyone who lands here.

https://www.drupal.org/project/drupal/issues/2981047#comment-15586793