Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294303

Updating an entity type from non-revisionable to revisionable fails if it has non-revisionable fields stored in dedicated tables

$
0
0

Problem/Motivation

Currently when you have a revisionable entity type with a non revisionable storage definition requiring dedicated table, the table mapping returns no dedicated revision table for it, while the storage and storage schema handlers expect the revision table to be there and try to read from/write to it. Since the table mapping is used to generate the temporary schema, the system ends up missing the field revision table when it starts copying data, as reported by Kate Heinlein in #3052464-47: Cannot update to 8.7.0 because of taxonomy_post_update_make_taxonomy_term_revisionable:

My taxonomy_post_update_make_taxonomy_term_revisionable was failing because I had fields on the terms which I created via hook_entity_field_storage_info / hook_entity_bundle_field_info.

SqlFieldableEntityTypeListenerTrait was then failing because it didn't had a temporary table created to copy the field items:

Drupal\Core\Entity\EntityStorageException: The entity update process failed while processing the entity type taxonomy_term, ID: 5. in Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->copyData() (line 216 of web/core/lib/Drupal/Core/Entity/Sql/SqlFieldableEntityTypeListenerTrait.php).

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'tmp_db11dbtaxonomy_term_revision__content_type' doesn't exist: INSERT INTO {tmp_db11dbtaxonomy_term_revision__content_type}

My solution was to make those fields revisionable before the update, and the update itself ran without errors.

Proposed resolution

The root cause of this issue is #3113639: The default table mapping and the SQL storage do not agree on whether non-revisionable bundle fields should get a revision table, however fixing that is not trivial, while to make the update work just "compensating" for the table mapping behavior in the storage schema handler so that also field revision tables are created is enough.

While investigating the issue, it was also suggested that this issue could be caused by running the update without installing the storage definitions. This turned out not to be the case but it is still ok to improve the docs as part fo the fix.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None, field revision tables for fields requiring dedicated storage are now created, as expected by the storage handler.

Release notes snippet

An issue preventing non-revisionable entity types from being successfully updated to revisionable when they define non-revisionable fields requiring dedicated field tables has been resolved.


Viewing all articles
Browse latest Browse all 294303

Trending Articles