Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
It is possible that the module installer when run during the config import does not use the config that comes with the module so It is important that we only add/edit config in hook_install
when config installer is not in syncing state. See #2550357: Fix shortcut_install() and shortcut_themes_installed(): Only update config when syncing flag is FALSE or forum_install().
Proposed resolution
Update the hook_install
documentation to accommodate that.
Remaining tasks
Review
Commit
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
hook_update-doc.patch | 1.54 KB | jibran | |
Comments
Comment #2
jhodgdonThis documentation addition does not give me enough information. I haven't read the referenced issue, and we cannot expect people who are reading the documentation of hook_install() to do so either.
The disconnect I have is this:
"make sure that config installer should not be in syncing state"
I do not know what this means, and this documentation does not explain it.
Comment #3
alexpottThis is a major task since getting this wrong means that enabling a module during config import is broken.
Comment #4
jibranAs far as my understanding, the current configuration and stored configuration can be different in
hook_install
.How?
When we install a module during config import at that point the current configuration and stored configuration are different because config import is changing the configuration so to make sure that we have valid/current configuration in
hook_install
we have to make sure that config installer is not in syncing state i.e.!\Drupal::service('config.installer')->isSyncing()
.Does it make sense? I don't know how to accommodate this in patch.
Comment #5
jhodgdonOK, that makes sense... But what should a module really do if config is in the process of synching? If its install tasks don't get done (if they're just skipped), the module won't be installed correctly.
Comment #6
jhodgdonActually, it seems like Drupal should really not allow you to install/uninstall modules while it's doing a config synch.
Comment #7
ifrikComment #8
jibranQuoting @alexpott from #2696593-17: Fix the module install during config import so it doesn't get lost in contrib tracker.
Comment #17
Amber Himes MatzI believe this issue should be closed as a duplicate of #2914174: Improve hook_install() to include recommendations for config import and pass an $is_syncing argument and maybe even #3039296: Fix examples in hook_install() and hook_uninstall(), both of which improve the documentation and examples in hook_install (and related hooks), and specifically consider the limitations and problems with attempting to update config during a sync. Specifically, the
$is_syncing
parameter was added to hook_install, along with a good description and warning. Also, example code was added to module.api.php which uses this parameter.