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

Comments

peximo created an issue. See original summary.

peximo’s picture

Issue summary: View changes
peximo’s picture

Attached patch should fix the issue.

tim bozeman’s picture

Status: Active » Reviewed & tested by the community

Thanks Pex!

  • tim bozeman committed 0656f11d on 2.3.x
    feat: #3585398 ToolPluginManager cache key and alter hook collide with...
tim bozeman’s picture

Status: Reviewed & tested by the community » 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.