\Drupal\Core\Entity\Sql\SqlContentEntityStorageSchemaConverter::convertToRevisionable is making a call to \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface::getLastInstalledFieldStorageDefinitions, but a typo introduced in #3004642: Deprecate SqlContentEntityStorageSchemaConverter in favor of the new API provided by EntityTypeListenerInterface::onFieldableEntityTypeUpdate() (committed 13 Feb 2019) hard coded the entity_test_update entity type instead of the entity type being updated.

   */
  public function convertToRevisionable(array &$sandbox, array $fields_to_update = []) {
    /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
    $this->entityTypeManager->useCaches(FALSE);
    $entity_type = $this->entityTypeManager->getDefinition($this->entityTypeId);

    /** @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface $last_installed_schema_repository */
    $last_installed_schema_repository = \Drupal::service('entity.last_installed_schema.repository');
    $field_storage_definitions = $last_installed_schema_repository->getLastInstalledFieldStorageDefinitions('entity_test_update');

Understandably SqlContentEntityStorageSchemaConverter was deprecated in 8.7, so usage in core has been eliminated. Existing code, especially before 8.7.x, and documentation refer to the convertToRevisionable method.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dpi created an issue. See original summary.

dpi’s picture

Status: Active » Needs review
FileSize
1001 bytes
dpi’s picture

Issue summary: View changes
jibran’s picture

Status: Needs review » Reviewed & tested by the community

Yeah, it happens.

dpi’s picture

Title: Cannot convert custom entity types from non-revisionable to revisionable » Cannot convert custom entity types from non-revisionable to revisionable with pre-8.7.x compatible methods
xjm’s picture

Status: Reviewed & tested by the community » Needs work

lol whoops.

This should probably have a test, which would clearly need to use an entity type other than a test entity type. ;) Assuming there are already tests that we can just add to?

xjm’s picture

Issue tags: +Needs tests
plach’s picture

SqlContentEntityStorageSchemaConverter is deprecated and should be no longer used, tests have been migrated over, which might explain why this slipped through.

plach’s picture

I'm not sure about this needing tests TBH.

xjm’s picture

I guess if it's a deprecated API there's a debate to be had about whether it needs tests (and I can probably predict which committers would take which positions on the matter). However, can we start by looking into how difficult test coverage would be first? If it's trivial there's no reason not to add it.

A workaround we could document in the IS is using the replacement API.

amateescu’s picture

IMO, writing test coverage for this is not trivial at all because we have only one entity type which is suited for update path tests, and.. you guessed it, it's the one from this patch: entity_test_update :)

alexpott’s picture

I'd be +1 to committing this without tests because it's an obvious error and just a mistake and it is something we broke in 8.7.x that was working in 8.6.x.

amateescu’s picture

I found another entity type which could be used for testing this: entity_test_new, so here's a quick test.

The last submitted patch, 13: 3052140-13-test-only.patch, failed testing. View results

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, this is ready now.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @dpi for filing the issue and @amateescu for writing tests and @xjm for asking for them.

Committed and pushed 20762532ac to 8.8.x and 2cdefde175 to 8.7.x. Thanks!

Backported to 8.7.x as this is an update critical.

  • alexpott committed 2076253 on 8.8.x
    Issue #3052140 by amateescu, dpi, xjm: Cannot convert custom entity...

  • alexpott committed 2cdefde on 8.7.x
    Issue #3052140 by amateescu, dpi, xjm: Cannot convert custom entity...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.