I am updating site from 8.7.1 to 8.7.6, and I'm getting strange error:

Error: Call to a member function getType() on null in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->getDedicatedTableSchema() (line 2213 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php)

Site seems to be working and the messages do get delivered. But when I go to admin/reports/status I get that error.

I have debugged this and it seems that there is id key missing from Message class definition.

This is based on the fact that $entity_type->getKey('id'); returns false on the contact_message entity type.

And when I debug EntityType::getKeys(), indeed there is no id key in the entity definition.

Also the id key is present in SqlContentEntityStorageSchema::fieldStorageDefinitions and when I manually include that id field definition I get rid of that error and status page works normally.

if (is_null($id_definition)) {
  $id_definition = $this->fieldStorageDefinitions['id'];

Of course this is not an solution, but perhaps someone can give me some pointers as to how to fix this. The production site is still in the latest 8.6.x release, and updating directly from that to current release gives me this error as well. Status page works normally in production, although it gives The Message ID field needs to be updated message.

There is no entity updates pending in the production environment, no matter how many times I run entity updates, the error message is still in the status page.

I tried sorting this out in update hook, in similar way that we've been updating our own custom entities since 8.7 update:

$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('id', 'contact_message');

This gives no errors, but messages still appear to be broken.

Apparently the message id has been broken for some time, but we haven't noticed any issues before this one.

Any and all help is appreciated.

  • 1
    The Message type has never had an id entity key according to the annotation (going back to at least 8.0). Perhaps it's been added (and subsequently mismanaged) by a contrib or custom module? – Clive Aug 20 '19 at 13:05
  • Check if entity contact_message base table is in database. – Gatis Rudins Sep 11 '19 at 11:05
  • @GatisRudins, yes, the table is present. And there is an ID field also. Seems that the annotation is only thing missing. We raised an issue from this in drupal.org as well, no traction yet: drupal.org/project/drupal/issues/3077604. Currently we're testing out very ugly workaround to patch SqlContentEntityStorageSchema.php so that this doesn't throw fatal error. Not sure if we can do this in production though. I'll update here. – Janne Suominen Sep 24 '19 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.