Problem/Motivation
The navigation_plus module defines its own ToolPluginManager in src/ToolPluginManager.php which uses the cache key tool_plugins and the alter hook tool_info:
$this->alterInfo('tool_info');
$this->setCacheBackend($cache_backend, 'tool_plugins'); The https://www.drupal.org/project/tool module (drupal/tool) provides a generic framework for defining executable tool plugins and uses the same tool_plugins cache key and tool_info alter hook in its own plugin manager. When both modules are installed together:
- Cache collisions — the two plugin managers share the same cache entry (tool_plugins), so one overwrites the other's cached definitions. This leads to missing or incorrect plugin definitions after a cache clear.
- Alter hook conflicts — implementations of hook_tool_info_alter() intended for one manager's plugins will incorrectly alter the other's definitions as well.
Steps to reproduce
1. Install both navigation_plus and tool (drupal/tool).
2. Clear caches.
3. Observe missing or incorrect tool plugin definitions from one or both modules.
Proposed resolution
Prefix the navigation_plus identifiers with the module name to avoid the collision:
$this->alterInfo('navigation_plus_tool_info');
$this->setCacheBackend($cache_backend, 'navigation_plus_tool_plugins');This follows the Drupal convention that plugin managers should use module-namespaced cache keys and alter hook names to prevent conflicts with other modules.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | navigation_plus-unique-cache-key-3585398-2.patch | 603 bytes | peximo |
Comments
Comment #2
peximo commentedComment #3
peximo commentedAttached patch should fix the issue.
Comment #4
tim bozeman commentedThanks Pex!
Comment #6
tim bozeman commented