Problem/Motivation

  • In #2326949: Move entity-type-specific schema information from the storage class to a schema handler, we introduced 'storage_schema' as another entity handler that can be specified in the entity type's annotation.
  • However, unlike our other handlers so far, this one is currently dependent on the 'storage' handler, in that SqlContentEntityStorageSchema has constructor arguments that EntityManager doesn't know about, and EntityManager also doesn't know about what the default class should be if it's not specified in the annotation, since that default would depend on the storage handler.
  • As a result, neither EntityManager itself, nor any other code external to the storage handler can interact with the storage schema handler directly: it can only interact with the storage handler, and it's up to the storage handler to delegate what it wants to the storage schema handler. This could be seen as either good or bad.
  • It also means that calling $entity_manager->getHandler('storage_schema') will break, and that's not documented anywhere. That also prevents EntityManager from being able to loop over all of its handlers reliably.

Proposed resolution

?

Remaining tasks

Decided what we want to do.

User interface changes

API changes

Comments

fago’s picture

The constructor argumetn shouldn't be problematic when implement EntityHandlerInterface::createInstance()?

Choosing the default seems to be more problematic though. We could just hard-code the default for sql-based storage in the EM, or we allow the storage to specify it + have a dumb EntityHandler implementation action as default-factory only? (it figures out the class from the storage an instantiates that).

Maybe, this could be solved properly by an event system which allows handlers to alter the entity definition to add in defaults?

Anway, for now, I think hard-coding the sql-based default in the EM is fine.

effulgentsia’s picture

The constructor argument shouldn't be problematic when implement EntityHandlerInterface::createInstance()?

A constructor argument being added in #2330121: Replace ContentEntityDatabaseStorage::getSchema() with a new EntityTypeListenerInterface implemented by SqlContentEntityStorageSchema is the $database connection. Presumably, the storage handler and the storage schema handler should act on the same database connection. An assumption we've made in the past with factory methods passed $container is that using those factory methods is optional, and that code should work properly if a consumer instantiates an object via its constructor, passing it arguments that don't need to match what's in the container.

So, suppose someone instantiates the storage handler with some other $database argument. How should ContentEntityDatabaseStorage::schemaHandler() be implemented? If it delegates to $entity_manager->getHandler('schema_storage') and that calls $schema_storage_class::createInstance($container), then that handler will get instantiated with a different $database than the storage handler is using.

fago’s picture

.. then that handler will get instantiated with a different $database than the storage handler is using.

I see, but making the storage_schema handler a separate handler makes it part of the public API. Given that I think it's ok to say: when you switch the database for the storage you should do so for the schema as well.

plach’s picture

Priority: Normal » Major

This looks major-ish to me...

plach’s picture

Issue tags: +entity storage

More or less...

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

Issue tags: +@todo clean-up

There are a bunch of @todos for this issue. I'm encountering it from trying to inject a keyvalue service as in #2729597: [meta] Replace \Drupal with injected services where appropriate in core, via SqlContentEntityStorageSchema::installedStorageSchema().

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

DamienMcKenna’s picture

Issue tags: -

FYI it seems this has lead to problems with EntityQueue, which resulted in a bug in distros that use it, e.g. #3126343: Scheduler needs to maintain its base fields properly.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

joseph.olstad’s picture

ya , still flustered by this one.

we cannot upgrade to entityqueue 1.0 and I've followed the various threads to get here.

the combination of lightning_workflow with entityqueue beta5 installation seems to expose a problem and I haven't found a contrib way to solve it yet.

joseph.olstad’s picture

Version: 8.9.x-dev » 9.1.x-dev

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.