Fatal error: Uncaught TypeError: EntityViewsData::mapFieldDefinition(): Argument #3 ($field_definition) must be of type FieldDefinitionInterface, null given

Created on 3 March 2025, about 1 month ago

Problem/Motivation

The following error appears when trying to run update hooks after updating the module from version 2.1.0-rc2 to 3.0.4:

Fatal error: Uncaught TypeError: Drupal\views\EntityViewsData::mapFieldDefinition(): Argument #3 ($field_definition) must be of type Drupal\Core\Field\FieldDefinitionInterface, null given, called in /[..]/web/core/modules/views/src/EntityViewsData.php on line 334 and defined in /[..]/web/core/modules/views/src/EntityViewsData.php:436
Stack trace:
#0 /[..]/web/core/modules/views/src/EntityViewsData.php(334): Drupal\views\EntityViewsData->mapFieldDefinition('easy_email', 'langcode', NULL, Object(Drupal\Core\Entity\Sql\DefaultTableMapping), Array)
#1 /[..]/web/core/modules/views/views.views.inc(180): Drupal\views\EntityViewsData->getViewsData()
#2 /[..]/web/core/modules/views/src/ViewsData.php(228): views_views_data()

Proposed resolution

It seems like you can't just remove a base field without doing some kind of cleanup: πŸ› TypeError EntityViewsData::mapFieldDefinition() null given Needs work .

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @dieterholvoet
  • πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

    It seems like this specific error is only triggered if you rebuild caches before executing update hooks. If you don't, the following warnings and error are logged:

    > [warning] Undefined array key "langcode" EntityViewsData.php:334
    >  [warning] Undefined array key "langcode" EntityViewsData.php:442
    >  [error]  Error: Call to a member function getSchema() on null in Drupal\views\EntityViewsData->mapFieldDefinition() (line 442 of /[..]/web/core/modules/views/src/EntityViewsData.php)
    > #0 /[..]/web/core/modules/views/src/EntityViewsData.php(334): Drupal\views\EntityViewsData->mapFieldDefinition('easy_email', 'langcode', NULL, Object(Drupal\Core\Entity\Sql\DefaultTableMapping), Array)
    > #1 /[..]/web/core/modules/views/views.views.inc(180): Drupal\views\EntityViewsData->getViewsData()
    > #2 /[..]/web/core/modules/views/src/ViewsData.php(228): views_views_data()
    > #3 /[..]/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(395): Drupal\views\ViewsData->Drupal\views\{closure}(Object(Closure), 'views')
  • πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

    Adding back the langcode key seems to fix these errors, but only without doing a cache rebuild before running update hooks. Also, a new error appears:

    Attempted to create, modify or delete a configurable field of non-configurable field storage key.

    I tried both drush updatedb and drush updatedb --no-cache-clear, both give the same result. I'm going to revert back to version 2 for now.

  • Merge request !39Add back the langcode key β†’ (Open) created by dieterholvoet
  • πŸ‡ΊπŸ‡ΈUnited States zengenuity

    These instructions should be in a more prominent location, but here are the steps to do a 2.x to 3.x upgrade: https://www.drupal.org/project/easy_email/releases/3.0.0-beta3 β†’

  • πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

    Wouldn’t it make more sense to create another v2 release instead of expecting people to discover this documentation and requiring them to install a dev release?

  • πŸ‡ΊπŸ‡ΈUnited States zengenuity

    I've added a link to the upgrade instructions on the module home page. It would be helpful if you could try those out and report back if they work for you. I haven't tried them since the 3.0 beta, so it would be good to confirm they still work. I think the only change that needs to be made is that you don't need to specifically run composer require 'drupal/easy_email:^3.0@beta'. I think running composer require 'drupal/easy_email:^3.0' to get the most recent version should be fine.

    As for creating a new 2.1.x release, I don't want to do that because people might upgrade without reading the release notes, breaking their site in the process. (or at least the email functionality) This upgrade process can only be done manually, so I don't think it's a problem to require people to temporarily install the dev release. I suppose we could create a 2.2.0 specifically for this purpose, but I don't want to clutter the module page with that, and people would still need to specifically require that release, so it's the exact same process to do it with the dev release.

  • πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

    Just tried updating from dev-2.2.x 7e69429 to 3.0.4, but it fails on the same error:

     ------------ ----------- --------------- -------------------------------------
      Module       Update ID   Type            Description
     ------------ ----------- --------------- -------------------------------------
      easy_email   10001       hook_update_n   10001 - Set the default value for
                                               accessing the email log report.
      easy_email   00005       post-update     Re-install new easy_email entity
                                               type
      easy_email   00006       post-update     Update the easy email types for the
                                               new settings.
      easy_email   00007       post-update     Copy data from temporary table to
                                               new easy_email entity type
      easy_email   00008       post-update     Delete the temporary table.
      easy_email   00009       post-update     Set default global settings
     ------------ ----------- --------------- -------------------------------------
    
    
     // Do you wish to run the specified pending updates?: yes.
    
    >  [notice] Update started: easy_email_update_10001
    >  [notice] Update completed: easy_email_update_10001
    >  [notice] Update started: easy_email_post_update_00005
    >  [notice] Update completed: easy_email_post_update_00005
    >  [notice] Update started: easy_email_post_update_00006
    >  [notice] Update completed: easy_email_post_update_00006
    >  [notice] Update started: easy_email_post_update_00007
    >  [error]  Attempted to create, modify or delete a configurable field of non-configurable field storage from_name.
    >  [error]  Update failed: easy_email_post_update_00007
     [error]  Update aborted by: easy_email_post_update_00007
     [error]  Finished performing updates.
    
  • πŸ‡ΊπŸ‡ΈUnited States zengenuity

    Did the drush updatedb complete successfully at 2.2.x-dev? One of the things it should have done was delete from_name in easy_email_post_update_00003(): https://git.drupalcode.org/project/easy_email/-/blob/2.2.x/easy_email.po...

  • πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

    Okay, it works now. Important to note: if you're deploying your site in an automatic way, through pipelines for example, you have to export and commit configuration changes after running both groups of update hooks.

Production build 0.71.5 2024