-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Bug Description
The admin_toolbar_tools module causes a fatal TypeError during Drupal site installation when the project_browser module is enabled and configured via recipes.
Error Message
[warning] Array to string conversion ExtraLinks.php:745
[error] TypeError: Unsupported operand types: int + string in Drupal\admin_toolbar_tools\Plugin\Derivative\ExtraLinks->getDerivativeDefinitions() (line 749 of /var/www/html/web/modules/contrib/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php)
Root Cause Analysis
The issue occurs in ExtraLinks.php at line 749 with this code:
'weight' => -10 + $key,Problem: During site installation via recipes, the project_browser.admin_settings config contains an enabled_sources array where the keys are strings ("0", "1") rather than integers (0, 1). When the code iterates over this array:
foreach ($project_browser_enabled_sources as $key => $source_id) {The $key variable contains string values, causing PHP to throw a TypeError when trying to perform arithmetic: int + string.
Why it works after installation: After site installation, Drupal's config system normalizes array keys to proper integers, so the arithmetic operation works correctly.
Reproduction Steps
- Set up a Drupal installation with recipes that include
project_browsermodule - Configure
project_browser.admin_settingswithenabled_sourcesin recipe YAML - Run
drush site:install - The error occurs during the menu rebuild process triggered by entity insertion hooks
Configuration Context
Recipe configuration that triggers the issue:
project_browser.admin_settings:
simpleConfigUpdate:
enabled_sources:
- drupalorg_jsonapi
- recipesProposed Solution
Cast the $key to integer before arithmetic operation:
'weight' => -10 + (int)$key,Or use array_values() to ensure numeric keys:
foreach (array_values($project_browser_enabled_sources) as $key => $source_id) {Environment
- Drupal Core: 11.x
- admin_toolbar version: Latest
- Installation method: Drupal Recipes via drush site:install
- Context: Site installation process
Impact
- Blocks site installation when admin_toolbar_tools and project_browser are both enabled
- Only affects installation process, not post-installation usage
- Workaround: Remove project_browser module or disable admin_toolbar_tools during installation
🤖 Generated with Claude Code