Problem/Motivation
I upgraded from 11.4 to 12.0.0-alpha1 and got repeated failures during text_update_12001().
field.storage.node.body:
id: node.body
field_name: body
entity_type: node
type: text_with_summary
module: text
persist_with_no_fields: true
No content type actually uses this storage in the exported configuration.
The text_with_summary module is not installed.
Steps to reproduce
- Install a Drupal 11.4 site.
- Upgrade the codebase and Composer dependencies to Drupal 12.0.0-alpha1.
- Run drush updatedb.
- text_update_12001() fails.
- Run updatedb again and it fails again.
Proposed resolution
updatedb should complete successfully.
Remaining tasks
Figure out what is causing this.
AI investigation:
The update hook loads field-storage entities before attempting to install the replacement module:
$storages = \Drupal::entityTypeManager()
->getStorage('field_storage_config')
->loadByProperties(['type' => 'text_with_summary']);
if ($storages !== []) {
\Drupal::service('module_installer')->install(['text_with_summary']);
}
Loading the storage calls FieldStorageConfigStorage::mapFromStorageRecords(), which requires the field-type plugin to resolve its class. This throws before execution reaches the module installation.
Issue fork drupal-3621016
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
Comment #2
ptmkenny commentedComment #5
longwaveWe can use entity query which won't actually load the field storage. Also added a test.
Comment #6
larowlanComment #7
smustgrave commentedSeems like a good defense. Marking as don't want any excuse to revert that removal
Comment #10
larowlanCommitted and pushed d107690b1ce to main and 642babcd8e1 to 11.x. Thanks!
Comment #14
amateescu commentedThe test added here has been breaking every MR pipeline on main with this message:
Reverted from main and 11.x for now.
Comment #15
catchI think this might be failing on main and not 11.x because
src/Plugin/Field/FieldType/TextWithSummaryItem.phpwas removed from 12.xI think we need to tell people that they have to update to at least 11.5.x before updating to 12.x if they have text_with_summary fields, in which case the update on main would need to be written to rethrow that exception if it runs with a useful message to install text_with_summary module. Or something like that.
Comment #16
catch11.x daily pipeline was green for mysqli which tends towards #15 being on the right lines https://git.drupalcode.org/project/drupal/-/pipelines/952544
Comment #18
ptmkenny commentedI don't know what the "right" fix is to this issue, but in my case, removing
field.storage.node.body.ymlfrom the exported config allowed me to update to Drupal 12 from 11.4 because I was not using text_with_summary, but text_with_summary was referenced in that config file.Comment #19
smustgrave commentedComment #20
smustgrave commentedwhat if we just fix the .install and leave the new test out?
Comment #21
smustgrave commentedWhat if we update the hook to check if text with summary exists too? If it doesn’t the assumption is someone jumped straight to 12 and could return a message they need to go get the contrib module?
Comment #22
longwaveI think the problem is that if another hook fires first and tries to load field definitions first then it will still crash? Also if they have part upgraded will the UI still work for them to enable the module, or are they stuck at that point?
Maybe we need to make the code that crashes more robust in some way, or leave behind a stub plugin or similar?
Not really sure what the right way to go is, just throwing out ideas that I thought of.
Comment #23
smustgrave commentedIf we add a stub like we did migrate_drupal will it still fail as the plugins are gone?
Comment #25
longwaveAs per #16, MR!17014 is still valid for 11.x, so I reopened that.
MR!17074 is my approach for main - add a requirements hook that refuses to continue if text_with_summary fields exist and the contrib module is not installed.
Comment #26
smustgrave commentedNew test appears to be failing TextWithSummaryUpdatePathTest
Comment #27
catchRequirements hook is a good plan and better than my idea to rethrow a more informative exception, moving back to RTBC.
Comment #28
smustgrave commentedJust happy we didn't need to revert :)
Comment #32
larowlanCommitted and pushed a3af6101cef to main.
Committed and pushed 14611e09455 to 11.x.
Thanks!