Problem/Motivation

In #1916790: Convert translation metadata into regular entity fields we added automatic notification of field storage definition creation to avoid forcing users to run updates before being able to translate content:

[The committed] patch makes the UX of enabling translation on an entity type for the first time slightly worse as updates need to be run before things actually work. I think we should add a method on the definition update manager to apply changes only pertaining a single provider (module). This would allow CT to update the schema automatically. I think this particular case does not need a manual confirmation by the user, unless a huge number of entity is already existing, which could make adding columns a very long operation.

The code added over there could be generalized and add onto the definition update manager, so other modules with similar use cases can leverage it. We also need to figure out how to deal with potentially long schema updates.

Proposed resolution

  • Add a method to the definition update manager to apply updates only for a specific provider.
  • Add a method to the entity manager to mark one or more entity/field storage definition as up-to-date, that is telling the system no more updates are required. This should cover especially changes to the field storage definition schema.

Remaining tasks

  • Solution definition
  • Implementation
  • Reviews

User interface changes

None

API changes

None, just additions

Comments

plach’s picture

Issue tags: +Entity Field API

One more tag

plach’s picture

Title: Clean up field storage definition handling after enabling translation for an entity type » Improve DX of manually adding/removing field storage definitions
Issue tags: +DX (Developer Experience)

Better title

plach’s picture

Issue tags: +entity storage
plach’s picture

Status: Active » Postponed
plach’s picture

Status: Postponed » Active
legolasbo’s picture

The regression mentioned in the issue summary has been filed as a bug report, sparking my interest.

In #2418563: Column not found: 1054 Unknown column 'content_translation_source' i've added a patch (including tests) to fix the regression.

dawehner’s picture

StatusFileSize
new2.6 KB

@catch asked me to post something here.

Due to various misbehaviours we ended up with a schema of DEV but using beta 6. This resulted in update.php pointing out various updates.

Here is small script which updates the various internal states so update.php doesn't want to update any longer.

PS: A slightly related issue #2441867: Don't require settings.php to be writeable in update.php

plach’s picture

Title: Improve DX of manually adding/removing field storage definitions » Improve DX of manually applying entity/field storage definition updates
Issue summary: View changes

Added proposed solution.

berdir’s picture

Sounds good to me. For context, here's an example update function that I wrote that needed the second part (being able to mark a certain field as manually updated): https://gist.github.com/Berdir/3bfdb91e664e325004ba.

Pretty complicated, mostly because many parts are protected right now. There's no way to get at the generated schema for a certain field for example.

jhedstrom’s picture

Seeing a need for this over in #2540990: Need to update stored schema data (h2h module). Would adding a public setSchema() be an option to work around the need for reflection?

The IS mentions marking storage schema as up-to-date, but this runs into the problem of update hooks not knowing about the current state of the schema when they are run.

jhedstrom’s picture

Status: Active » Needs review
Issue tags: +D8 upgrade path
StatusFileSize
new2.05 KB

Perhaps something along these lines.

Status: Needs review » Needs work

The last submitted patch, 12: storage-definition-updates-2346013-12.patch, failed testing.

jhedstrom’s picture

Status: Needs work » Needs review
StatusFileSize
new535 bytes
new2.57 KB

Perhaps this.

berdir’s picture

The point of my callback/event idea is that you don't have to worry about this. You'd be responsible for setting the schema to the target field definition/schema that you get passed in. And you just need to confirm that you updated a given field which then has the same result as if the field was automatically updated.

jhedstrom’s picture

@berdir that makes a ton of sense, I just wasn't clear on the exact details of the callback.

So would we implement an event that modules could subscribe to, the schema would be passed along to those subscribers, and they would a) fire any database manipulation, and then b) update the passed schema to their current state?

The entity update system would then store that schema, and if it still doesn't match the latest schema, the automated update system would continue to send out events until another listener fixed the schema?

plach’s picture

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.

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.

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.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.

quietone’s picture

Updating tag.

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new159 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

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

mfb’s picture

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

This issue seems still relevant today? I wanted to figure out how a contrib field type would go about updating its schema.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.