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.

Command icon 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

danherrero created an issue. See original summary.

danherrero’s picture

Title: hook_install() calls drupal_flush_all_caches() unnecessarily, causing a race condition during site installation » Remove unnecessary node access rebuild flag and full cache flush from hook_install()
Category: Bug report » Task

joshahubbers made their first commit to this issue’s fork.

joshahubbers’s picture

Thank 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.

  • 517dc995 committed on 3.x
    Issue #3589004 by danherrero: Add remark to README
    
joshahubbers’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.