While writing an upgrade path test for #1846172: Replace the actions API, I ran into a bit of a problem.
system_update_8046() calls config_install_default_config('module', 'node');
, which prematurely installs the new config I'm trying to update to.
Also, when doing config entity upgrades, we had to use config() directly, and not use entity_create().
But config_install_default_config() still invokes the storage controllers importCreate(), which is still calls EntityStorageControllerInterface::create() and EntityStorageControllerInterface::save()!
It is called by:
user_update_8011()
system_update_8046()
Comment | File | Size | Author |
---|---|---|---|
#17 | config-1998204-17.patch | 4.57 KB | tim.plunkett |
#17 | interdiff.txt | 1.83 KB | tim.plunkett |
#14 | config-1998204-14.patch | 2.93 KB | tim.plunkett |
#11 | config-1998204-11.patch | 2.66 KB | tim.plunkett |
#6 | config-1998204-6.patch | 1.14 KB | tim.plunkett |
Comments
Comment #1
catchComment #2
dcam CreditAttribution: dcam commentedhttp://drupal.org/node/1427826 contains instructions for updating the issue summary with the summary template.
Comment #3
tim.plunkettThe direction #2001310: Disallow firing hooks during update is headed will solve this problem for us. But because that is only a sideaffect, we shouldn't close this until we're sure that goes in in a way that obsoletes this issue.
Comment #4
BerdirThe latest patch in there removes the last call to it in the upgrade path and makes sure that we can't add new ones, as that would trigger hook_entity_info(), which in turn would throw an exception.
So I *think* we're good here but let's wait until that issue is in.
Comment #5
tim.plunkettWe still will want a helper function for the approach taken in system_update_8046().
Something like
Comment #6
tim.plunkettI had no idea we had this function.
Comment #7
chx CreditAttribution: chx commentedWow. I didn't know either and I should know these things.
Should we replace some / most / all of http://drupalcode.org/project/drupal.git/blob/9d73599020c282ed79294dcb41... with this function you found?
Comment #8
tim.plunkettupdate_7_to_8_install_default_config() was added in #1712250: Convert theme settings to configuration system, of all places.
The code in UpdateModuleHandler::enable() is a bit different, it loops through all files in /config and writes them.
This is just for picking individual files. I think they can be separate.
I do think we should rename this to update_install_default_config().
Honestly it'd be really cool if somehow config_install_default_config() was controlled by ModuleHandler somehow, so it could be swapped out for this function... Not sure if that's reasonable/possible.
----
My only concern is this scenario:
Assume that we're on 8.0-rc1, and we're supporting head2head upgrade path.
We add a new config file, called history.bananas.yml to core/modules/history/config/history.bananas.yml
In history_update_8666() we call
$success = update_7_to_8_install_default_config('module', 'history.bananas');
And then based on $success, we do something important.
This is committed, and is subsequently in 8.0-rc2.
If you run 8.0-rc1..8.0-rc2 updates, $success will be TRUE.
If you run 7.x..8.0-rc2 updates, $success will be FALSE.
Because
node_update_8012()
already ranmodule_enable(array('history'));
, which would have blanket-installed all of history's config, including history.bananas.yml.Comment #9
chx CreditAttribution: chx commentedI believe you read update_7_to_8_install_default_config wrong. It returns FALSE in this case only:
It will only return FALSE if the core/modules/history/config/history.bananas.yml file does not exist. If it exists, it will blindly install it again and return TRUE.
Comment #10
catchEven if the return value is the same, this still introduces two different code paths, it's a similar problem to installing a module with a schema, then updating the schema later, for that we added hook_schema_0().
Comment #11
tim.plunkettLet's just do it then.
Comment #12
catchComment #13
catchWhat if we enforce specifying the install of individual config files in updates. When a new file is added, a new update handler gets added for that file. That way regardless of when the update is run the configuration gets installed in the same order.
Comment #14
tim.plunkettTwo of the four times this is called, its installing a specific file. The other times, its in a foreach loop.
I don't think my concerns were actually valid.
Comment #15
dawehnerIt seems to be that there should be an issue which uses this functionality for system_update_8046 and therefore need the new parameter.
Comment #16
alexpottThis new functionality is not used in this patch... either we should remove it or convert system_update_8046() to use it.
Comment #17
tim.plunkettFine by me!
Comment #19
alexpott#17: config-1998204-17.patch queued for re-testing.
Comment #20
jibranBack to RTBC.
Comment #21
alexpottCommitted 50ae478 and pushed to 8.x. Thanks!
Comment #22.0
(not verified) CreditAttribution: commentedUpdated issue summary.