Strange "Mismatched entity and/or field definitions" error

I know there are plenty of other threads about this but I believe mine is a strange one and I’ve spent the last day debugging its cause with no luck so far, so hoping someone with more knowledge about schemas/field storage can help me.

First, a little background on what I am doing. I have a set of config which is packaged up using the features module and deployed as a package to a number of our other sites. Part of this feature set are a number of feed types for importing content into nodes. When I deploy this feature on 1 site, I get the "Mismatched entity and/or field definitions" error for the feeds_item field. On the other site I deploy it to, I don’t get any error. The fact it errors on one, but not the other is odd.

Mismatched entity and/or field definitions

I traced the issue to SqlContentEntityStorageSchema::requiresFieldStorageSchemaChanges. In particular, what is happening is that the value of $installed_schema is an empty array on the site with the error but has data on the site without the error.

  /**    * {@inheritdoc}    */   public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {     $table_mapping = $this->getTableMapping($this->entityType);      if (       $storage_definition->hasCustomStorage() != $original->hasCustomStorage() ||       $storage_definition->getSchema() != $original->getSchema() ||       $storage_definition->isRevisionable() != $original->isRevisionable() ||       $table_mapping->allowsSharedTableStorage($storage_definition) != $table_mapping->allowsSharedTableStorage($original) ||       $table_mapping->requiresDedicatedTableStorage($storage_definition) != $table_mapping->requiresDedicatedTableStorage($original)     ) {       return TRUE;     }      if ($storage_definition->hasCustomStorage()) {       // The field has custom storage, so we don't know if a schema change is       // needed or not, but since per the initial checks earlier in this       // function, nothing about the definition changed that we manage, we       // return FALSE.       return FALSE;     }      $current_schema = $this->getSchemaFromStorageDefinition($storage_definition);     $this->processFieldStorageSchema($current_schema);     $installed_schema = $this->loadFieldSchemaData($original);     $this->processFieldStorageSchema($installed_schema);      return $current_schema != $installed_schema;   } 

If I check inside the key_value table with these query select * from key_value where collection like 'entity.storage_schema.sql' and name like 'node.field_schema_data.feeds_item'; it is also empty on 1 but not the other:

So, somewhere, somehow the schema hasn’t been installed properly on one site. I can fix it by installing the devel-entity-updates module or writing an update hook that simply resaves the existing field storage definition but I’m hoping someone has some insight as to why this is happening. Thankyou!

N.B The site with errors is running on Drupal 9.2.10 while the site without errors is running on 9.2.11 but I’m not sure that makes a difference.

Also, I should point out that the fields are actually installed fine and working. It’s just the mismatch error that is the problem.

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Strange "Mismatched entity and/or field definitions" error

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.