Problem/Motivation

Some the kerneltests install entity schema's, install module configuration and create content. MongoDB is a bit stricter in the order of execution those actions. For MongoDB first the entity schema's need to be installed. Next the module configuration can be installed. Only then can content be created. With MongoDB entity fields are stored in the JSON document. Creating entity fields without the entity schema being installed will result in an error like:

Exception when installing config for module node, message was: Exception thrown while performing a schema update. Cannot add embedded table node_all_revisions__body to the node_all_revisions, because node_all_revisions doesn't exist.

MongoDB is also stricker in having dependent modules being installed. For instance the media entity has a dependecy on the user module. When the user module is not installed and the user entity schema installed, you get the following error:

Drupal\Core\Field\FieldException: Field 'revision_user' on entity type 'media' references a target entity type 'user' which does not exist.

Proposed resolution

Change the order of installing entity schema's, installing module configuration and content creation.

Remaining tasks

TBD

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

None

Issue fork drupal-3475719

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

daffie created an issue. See original summary.

daffie’s picture

Status: Active » Needs review
johnwebdev’s picture

Status: Needs review » Reviewed & tested by the community
needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new11.02 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

daffie’s picture

Status: Needs work » Reviewed & tested by the community

Rerolled the MR. Back to RTBC.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

daffie’s picture

Status: Needs work » Reviewed & tested by the community

Rebased and back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Not sure how this is going to be maintained unless mongo is in core :)

Maybe it is possible to add a listener in kernel tests to ensure that the entity schema is installed before creating a field on it?

daffie’s picture

Status: Needs work » Needs review

Maybe it is possible to add a listener in kernel tests to ensure that the entity schema is installed before creating a field on it?

I have added a listener to the kerneltestbase class and found a new instance were an entity schema was not created: Drupal\Tests\layout_builder\Kernel\ConfigActionsTest. The test was added a week ago in #3486981: Allow recipes to enable Layout Builder via config actions.

@alexpott: Thank you for the review and your suggestion how to make it better.

mondrake’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

This is very nice regardless of MongoDb in its enforcing proper dependencies of actions.

Is it possible to add a test for the new subscriber? More comments inline in the MR.

daffie’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

All remarks on the MR by @mondrake have been addressed.
A test has been added for the new field storage create check subscriber.
Back to NR.

@mondrake: Thank you for the review.

mondrake’s picture

few more nits commented inline

daffie’s picture

Applied the requested changes.

@mondrake: Thanks for the review.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Nice! LGTM now. Triggered tests for SQLite and PgSql.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

@daffie the event listener turned out great! Think we need to make a small adjustment for non core tests and trigger a deprecation until Drupal 12. See MR for suggestion for how to do this.

daffie’s picture

Status: Needs work » Needs review

The requested warning has been added for non-core tests.
Back to NR.

@alexpott: Thank you for the review.

alexpott’s picture

@daffie the changes look great. Will commit once this is rtbc again

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

#16 is addressed, back to RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 7f54341 and pushed to 11.x. Thanks!

  • alexpott committed 7f543411 on 11.x
    Issue #3475719 by daffie, mondrake, alexpott: Set entity schema...

Status: Fixed » Closed (fixed)

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