We have observed that calling drupal_flush_all_caches() in prevent_homepage_deletion_install() introduces a race condition when the module is installed as part of a fresh site install (e.g. via a profile or drush site:install). Drupal's module installer already performs the necessary cache rebuilds. Calling drupal_flush_all_caches() mid-install disrupts caches that are still being constructed, causing the installation to fail.
node_access_needs_rebuild(TRUE) is also incorrect for this module. That flag is intended for modules that implement hook_node_grants() and hook_node_access_records(), which write to the node_access table and require a batch rebuild. This module only implements hook_node_access(), a dynamic per-request hook that does not interact with the node_access table at all. Flagging a rebuild is unnecessary.
Steps to reproduce
1. Add prevent_homepage_deletion to an installation profile or run drush site:install on a site that includes the module.
2. Observe a fatal error or incomplete install caused by the premature cache flush.
Proposed resolution
Remove both calls from prevent_homepage_deletion_install().
Remaining tasks
- Review and apply patch
- Confirm site installation completes cleanly with the module present
User interface changes
None directly. Indirectly, admins will no long see the "rebuild permissions" notice after installing this module.
API changes
None.
Data model changes
None.
Issue fork prevent_homepage_deletion-3589004
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
danherrero commentedComment #5
joshahubbers commentedThank you for sharing your findings en creating a merge request. I removed the install file entirely, because an empty file is not needed.
I will add a not in the readme to flush caches if needed.
I will create a new version.
Comment #8
joshahubbers commented