Problem/Motivation
When updating Drupal CMS to Drupal 11.2.3 I get this on drush updatedb:
TypeError: Unsupported operand types: int + string in Drupal\admin_toolbar_tools\Plugin\Derivative\ExtraLinks->getDerivativeDefinitions() (line 749
Drupal CMS uses Project Browser, which changed how it's keying things, it seems, so the $key we iterate is no longer numeric.
foreach ($project_browser_enabled_sources as $key => $source_id) {
$links['project_browser.browse.' . $source_id] = [
'route_name' => 'project_browser.browse',
'parent' => 'system.modules_list',
// Menu items are ordered by the enabled sources.
'weight' => -10 + $key,
....
Steps to reproduce
Update Drupal CMS to Drupal 11.2.3 with drush updatedb:
drush updatedb
[warning] Drupal requires databases that support JSON storage.
(Currently using Database support for JSON Available
)
[warning] Package Manager is available for early testing. To install the module set the
value of 'testing_package_manager' to TRUE in your settings.php file.
┌ Requirements check reports errors. Do you wish to continue? ─┐
│ Yes │
└──────────────────────────────────────────────────────────────┘
----------------- --------------- ------------- ----------------------------
Module Update ID Type Description
----------------- --------------- ------------- ----------------------------
project_browser convert_enabl post-update Updates Project Browser
ed_sources_to settings to support
_arrays source-specific
configuration.
project_browser rebuild_conta post-update Clears the cache so that
iner_for_oo_h Project Browser's OO hooks
ooks are registered.
----------------- --------------- ------------- ----------------------------
┌ Do you wish to run the specified pending updates? ───────────┐
│ Yes │
└──────────────────────────────────────────────────────────────┘
> [notice] Update started: project_browser_post_update_convert_enabled_sources_to_arrays
> [notice] Update completed: project_browser_post_update_convert_enabled_sources_to_arrays
> [notice] Update started: project_browser_post_update_rebuild_container_for_oo_hooks
> [notice] Update completed: project_browser_post_update_rebuild_container_for_oo_hooks
[success] Finished performing updates.
[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 /.../modules/contrib/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php) #0 /.../core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(101): Drupal\admin_toolbar_tools\Plugin\Derivative\ExtraLinks->getDerivativeDefinitions()
#1 /.../core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(87): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives()
#2 /.../core/lib/Drupal/Core/Menu/MenuLinkManager.php(127): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions()
#3 /.../core/lib/Drupal/Core/Menu/MenuLinkManager.php(152): Drupal\Core\Menu\MenuLinkManager->getDefinitions()
#4 /.../core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php(62): Drupal\Core\Menu\MenuLinkManager->rebuild()
#5 /.../core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php(50): Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->menuLinksRebuild()
#6 /var/www/vendor/symfony/event-dispatcher/EventDispatcher.php(246): Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->onRouterRebuild()
#7 /var/www/vendor/symfony/event-dispatcher/EventDispatcher.php(206): Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}()
#8 /var/www/vendor/symfony/event-dispatcher/EventDispatcher.php(56): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
#9 /.../core/lib/Drupal/Core/Routing/RouteBuilder.php(209): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
#10 /.../core/lib/Drupal/Core/ProxyClass/Routing/RouteBuilder.php(83): Drupal\Core\Routing\RouteBuilder->rebuild()
#11 /.../core/includes/common.inc(473): Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild()
#12 /var/www/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(96): drupal_flush_all_caches()
#13 [internal function]: Drush\Commands\core\UpdateDBCommands->updatedb()
#14 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
#15 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#16 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(175): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#17 /var/www/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(387): Consolidation\AnnotatedCommand\CommandProcessor->process()
#18 /var/www/vendor/symfony/console/Command/Command.php(318): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#19 /var/www/vendor/symfony/console/Application.php(1092): Symfony\Component\Console\Command\Command->run()
#20 /var/www/vendor/symfony/console/Application.php(341): Symfony\Component\Console\Application->doRunCommand()
#21 /var/www/vendor/symfony/console/Application.php(192): Symfony\Component\Console\Application->doRun()
#22 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
#23 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
#24 /var/www/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run()
#25 /var/www/vendor/bin/drush.php(119): include('...')
#26 {main}.
TypeError: Unsupported operand types: int + string in /.../modules/contrib/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php on line 749 #0 /.../core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(101): Drupal\admin_toolbar_tools\Plugin\Derivative\ExtraLinks->getDerivativeDefinitions()
#1 /.../core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(87): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives()
#2 /.../core/lib/Drupal/Core/Menu/MenuLinkManager.php(127): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions()
#3 /.../core/lib/Drupal/Core/Menu/MenuLinkManager.php(152): Drupal\Core\Menu\MenuLinkManager->getDefinitions()
#4 /.../core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php(62): Drupal\Core\Menu\MenuLinkManager->rebuild()
#5 /.../core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php(50): Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->menuLinksRebuild()
#6 /var/www/vendor/symfony/event-dispatcher/EventDispatcher.php(246): Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->onRouterRebuild()
#7 /var/www/vendor/symfony/event-dispatcher/EventDispatcher.php(206): Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}()
#8 /var/www/vendor/symfony/event-dispatcher/EventDispatcher.php(56): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
#9 /.../core/lib/Drupal/Core/Routing/RouteBuilder.php(209): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
#10 /.../core/lib/Drupal/Core/ProxyClass/Routing/RouteBuilder.php(83): Drupal\Core\Routing\RouteBuilder->rebuild()
#11 /.../core/includes/common.inc(473): Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild()
#12 /var/www/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(96): drupal_flush_all_caches()
#13 [internal function]: Drush\Commands\core\UpdateDBCommands->updatedb()
#14 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
#15 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#16 /var/www/vendor/consolidation/annotated-command/src/CommandProcessor.php(175): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#17 /var/www/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(387): Consolidation\AnnotatedCommand\CommandProcessor->process()
#18 /var/www/vendor/symfony/console/Command/Command.php(318): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#19 /var/www/vendor/symfony/console/Application.php(1092): Symfony\Component\Console\Command\Command->run()
#20 /var/www/vendor/symfony/console/Application.php(341): Symfony\Component\Console\Application->doRunCommand()
#21 /var/www/vendor/symfony/console/Application.php(192): Symfony\Component\Console\Application->doRun()
#22 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
#23 /var/www/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
#24 /var/www/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run()
#25 /var/www/vendor/bin/drush.php(119): include('...')
#26 {main}
TypeError: Unsupported operand types: int + string in Drupal\admin_toolbar_tools\Plugin\Derivative\ExtraLinks->getDerivativeDefinitions() (line 749 of /.../modules/contrib/admin_toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php).
[warning] Drush command terminated abnormally.
Proposed resolution
I don't know if these are of any help:
https://www.drupal.org/project/entity_update/issues/3342851
https://www.drupal.org/project/smart_date/issues/3443532
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
maxilein commentedComment #4
vinodhini.e commentedHi @maxilein,
Steps to Reproduce (Unable to Replicate the Issue):
1. Upgraded Drupal core from 11.2.2 to 11.2.3.
2. Ran database updates using: drush updb
3. The update ran successfully without any errors. Unable to reproduce the reported issue.
Could you please provide more details or specific steps so I can attempt to reproduce the issue on my setup?
Comment #5
julien commentedHi @maxilein,
Here is a quick patch to fix those errors while running updates.
Comment #6
maxilein commentedThank you Julien. That patch made the errors go away when upgrading.
More information on the Drupal CMS upgrade for vinodhini.e:
And the final working result with the patch included:
Comment #9
chrisfromredfinTo reproduce this you must be using latest Project browser.
Project Browser changed how it's keying things, it seems, so the $key we iterate is no longer numeric.
I've confirmed that the order the user places them in matches the order they end up in the config object in, so I would say it might make sense to just iterate based on the array positions. However, the current iteration of the patch just does
(int) $keywhich is always a string and would make them all have the same weight.I have opened an MR based on the patch, but with some different intelligence for handling the weighting (which was the real issue in the first place).
Comment #10
jurriaanroelofs commentedThank you for the ground work, the first patch seems maybe a bit overly defensive with checks that are not strictly related to the problem and then to prevent the error it casts the string value to int making it zero, so in that case the problem is not really solved because the original ordering of Project Browser links is not preserved (because all weights are now 0).
Here is a simple patch that uses a counter to preserve the original ordering of Project Browser links to address the issue.
Comment #11
jurriaanroelofs commentedComment #12
jurriaanroelofs commentedSorry Im late to the party I see chrisfromredfin had already figured this out, I made this patch yesterday and just remembered I had not posted it yet. I also noticed the enormous diff on the MR, we only need to change a handful of lines so maybe something went wrong there.
Comment #13
ressaThanks for reporting and clarifying the error source and task, I am updating the Issue Summary.
It does look like the GitLab MR is pretty big, so maybe the Status should be "Needs work"?
Comment #14
chrisfromredfinYeah, I think the huge diffstat is a result of formatting it for coding standards, because I thought we needed to (Pipeline is failing for phpcs).
I think we should apply the patch from 10 into !169 and push that and re-mark Needs Review. Setting back to Needs Work; hopefully ressa can do that work and then re-mark NR?
Comment #16
dydave commentedThanks everyone for the great help on this issue!
Quick update of the merge request, as an attempt to keep this moving along with testing and reviews:
I haven't really had the time to test this myself manually though, with the Project Browser module installed and all...
So testing, comments and feedback would be greatly appreciated!
Back to Needs review!
Thanks in advance!
Comment #17
mably commentedSuccessfully tested on Drupal 11.2.5 and Admin Toolbar 3.6.2.
Comment #18
dydave commentedComment #19
robloachI tested this MR on Drupal 10, and it seems to work there too. Thanks a lot.
Comment #21
dydave commentedThanks again everyone!
This issue was really easy to reproduce:
Install admin_toolbar_tools 3.x (3.6.2, for example) and project_browser 2.1.x (2.1.1, for example).... The error described in the IS would immediately occur.
The initial issue #3506824: Compatibility with Project Browser was fixed to support project_browser 2.0.x which had the following config structure: an array of source ID values
https://git.drupalcode.org/project/project_browser/-/blob/2.0.0-beta1/co...
and now with project_browser 2.1.x the config is an associative array keyed by source IDs
https://git.drupalcode.org/project/project_browser/-/blob/2.1.x/config/i...
Change introduced in:
https://git.drupalcode.org/project/project_browser/-/commit/2e70410ced6e...
Corresponding to #3533955: Make source plugins support stored configuration options
I tried the previous merge request which indeed fixed the error, but the links under the "Extend" menu (
/admin/modules) would disappear.... defeating the purpose of having this code in the module in the first place.I have created a new merge request MR !185 which not only fixes the error but also restores the initial behavior of the extra links logic by adding all the enabled project browser sources extra links under the "Extend" menu item, see screenshot below:

This patch implies dropping support for earlier versions of Project Browser, in other words, users would have to upgrade and use the latest versions: 2.1.x.
Therefore a conflict constraint was added to module's
composer.jsonfile as an attempt to prevent users from using Admin Toolbar's next release with any version of Project Browser lower than 2.1.0, see:Could you please help testing and reviewing MR !185?
Could you please also review the conflict section? I'm not sure how this could really be tested without merging the changes in the module, since composer constraints and requirements are usually evaluated before patches are applied...
I checked in other contrib modules, for example
devel, copied theconflictsection and adapted the version compatibility constraint.I've done some quick tests myself and the logic seems to work exactly as it did for previous Project Browser versions:
/admin/config/development/project_browser) should immediately reflect the changes in the menu.Moving issue back to Needs review as an attempt to get more testing feedback and reviews on this new suggested patch.
Feel free to let us know if you encounter any issues with the suggested merge request or if you have any questions or concerns on any aspects of this comment or this ticket in general, we would certainly try answering as soon as possible.
Thanks in advance!
Comment #23
dydave commentedSince this feature keeps breaking with changes to Project Browser, I thought we might need an automated integration Functional test that would help systematically testing the integration with the evolution of core, admin_toolbar and project_browser.
Added a basic Functional tests class to check the links added by admin_toolbar_tools for project_browser are displayed in the expected order under the 'Extend' menu link.
Hopefully, this should help preventing these types of issues from repeating over and over in the future.
Reviews, feedback and comments are welcome.
Thanks in advance!
Comment #24
noonoos commentedBeen dealing with this issue for about 2 months after trialing CMS but not high priority as can get by without tools operating. Originally thought it was a download issue as download failed. Anyhow thought I would try turning off what ever the button is in project browser config with the result I have the following error.
Comment #25
dydave commentedCould anyone encountering this issue please try the patch from MR !185?
(see #21 above for more details)
Download the patch in plain diff format at the following URL:
https://git.drupalcode.org/project/admin_toolbar/-/merge_requests/185.diff
and apply it to your project as for any patch for contrib modules.
We're waiting on additional feedback and reviews before getting these changes added to the module....
Thanks in advance!
Comment #26
drupatz commentedI've this issue with 3.6.2 and Drupal 11.3.0-rc1. With the patch from MR!185 the issue is gone --- perfect!
Comment #27
drupatz commentedComment #29
dydave commentedThanks a lot Thomas (@drupatz) for your positive feedback and confirmation the patch fixed the issue! 🙏
Following your confirmation, I added a few minor changes to the doc comments blocks of the new Functional tests file and did another round of testing manually locally.
The links added by the module worked great with the correct order in the admin toolbar menu. 👌
Since everything seemed to work fine and the automated tests or jobs were all passing 🟢, I went ahead and merged the changes above at #28. 🥳
Note the
'conflict'constraint in thecomposer.jsonfile seems to work fine as well, since composer jobs for certain core versions (previous major, for example) appear to be unable to find a compatible version (greater than 2.1.0) package and thus, required a special case to conditionally skip the Functional test. 👍The changes should be released soon with the upcoming 3.6.3...
This is definitely an important issue we're glad to cross off our list... just a few more to go 😅
Since I don't see anything else remaining or any follow-up task for this ticket for the moment, it is probably safe to consider it as Fixed for now.
The added Functional tests should allow us to detect any breaking changes with the different versions of the Project Browser module and be able to address them quicker or even anticipate them earlier.
This should make the two modules integration more robust and hopefully, decrease the amount of maintenance work on our side or support requests we get to fix this particular feature 😅🤞
In any case, feel free to let us know if you still encounter any issues with the two modules, or would have any questions on any of the most recent code changes, we would certainly be glad to help! 😊
Once again, thanks a lot to everyone for the great help keeping the Admin Toolbar Tools module well maintained! 🙏
Cheers!