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:
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_browser module
- Configure
project_browser.admin_settings with enabled_sources in 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
- recipes
Proposed 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
Bug Description
The
admin_toolbar_toolsmodule causes a fatal TypeError during Drupal site installation when theproject_browsermodule is enabled and configured via recipes.Error Message
Root Cause Analysis
The issue occurs in
ExtraLinks.phpat line 749 with this code:Problem: During site installation via recipes, the
project_browser.admin_settingsconfig contains anenabled_sourcesarray where the keys are strings ("0", "1") rather than integers (0, 1). When the code iterates over this array:The
$keyvariable 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
project_browsermoduleproject_browser.admin_settingswithenabled_sourcesin recipe YAMLdrush site:installConfiguration Context
Recipe configuration that triggers the issue:
Proposed Solution
Cast the
$keyto integer before arithmetic operation:Or use
array_values()to ensure numeric keys:Environment
Impact
🤖 Generated with Claude Code