All my modules are in the web/modules/ directory except for Admin Toolbar which is in web/modules/contrib/. (Why? Long story, legacy site.) Admin Toolbar refuses to update now because of the inconsistency.

I temporarily changed the composer modules directory to web/modules/contrib/ and uninstalled the toolbar flushing the cache all along the way. I then removed the admin_toolbar directory and the composer.json entry. I changed the composer directory back to web/modules/ and installed Admin Toolbar again (doing more cache flushing). Everything's fine until I enable the module. It breaks the site and returns:

TypeError: Drupal\Core\Render\Renderer::doTrustedCallback(): Argument #1 ($callback) must be of type callable, array given, called in /var/www/html/yln/web/core/lib/Drupal/Core/Render/Renderer.php on line 788 in Drupal\Core\Render\Renderer->doTrustedCallback() (line 51 of core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php). 

Is there some way to fix this? Is there something in the database that could be manually edited to get around this problem? I'm on Drupal 9.

Update: Here's my json file.

    "name": "drupal/recommended-project",
    "description": "Project template for Drupal 9 projects with a relocated document root",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "homepage": "https://www.drupal.org/project/drupal",
    "support": {
        "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
        "chat": "https://www.drupal.org/node/314178"
    "repositories": {
        "0": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
    "require": {
        "composer/installers": "^1.9",
        "drupal/addtocal_augment": "^1.1@beta",
        "drupal/admin_toolbar": "^3.4",
        "drupal/block_visibility_groups": "^2.0",
        "drupal/bootstrap": "^3.28",
        "drupal/bootstrap5": "^3.0",
        "drupal/core-composer-scaffold": "^9.3",
        "drupal/core-project-message": "^9.3",
        "drupal/core-recommended": "9.5.9",
        "drupal/date_augmenter": "^1.1@beta",
        "drupal/devel": "^5.1",
        "drupal/easy_breadcrumb": "^2.0",
        "drupal/entity_print": "^2.11",
        "drupal/extlink": "^1.7",
        "drupal/fullcalendar_view": "^5.1",
        "drupal/libraries": "^4.0",
        "drupal/linkchecker": "^1.1",
        "drupal/mimemail": "^1.0@alpha",
        "drupal/multiple_fields_remove_button": "^2.2",
        "drupal/r4032login": "^2.2",
        "drupal/search_api": "^1.29",
        "drupal/search_api_autocomplete": "^1.7",
        "drupal/search_api_solr": "^4.2",
        "drupal/search_api_spellcheck": "^4.0",
        "drupal/slick": "^2.7",
        "drupal/smart_date": "^4.0",
        "drupal/tagclouds": "^2.0",
        "drupal/twig_tweak": "^3.2",
        "drupal/typed_data": "^1.0@beta",
        "drupal/upgrade_status": "^4.0",
        "drush/drush": "^11",
        "mikehaertl/phpwkhtmltopdf": "~2.1",
        "tecnickcom/tcpdf": "~6"
    "conflict": {
        "drupal/drupal": "*"
    "minimum-stability": "stable",
    "prefer-stable": true,
    "config": {
        "sort-packages": true,
        "allow-plugins": {
            "composer/installers": true,
            "drupal/core-composer-scaffold": true,
            "drupal/core-project-message": true
    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": "web/"
        "installer-paths": {
            "web/core": [
            "web/libraries/{$name}": [
            "web/modules/{$name}": [
            "web/profiles/{$name}": [
            "web/themes/{$name}": [
            "drush/Commands/contrib/{$name}": [
            "web/modules/custom/{$name}": [
            "web/profiles/custom/{$name}": [
            "web/themes/custom/{$name}": [
        "drupal-core-project-message": {
            "include-keys": [
            "post-create-project-cmd-message": [
                "<bg=blue;fg=white>                                                         </>",
                "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",
                "<bg=blue;fg=white>  from the drupal/recommended-project template!          </>",
                "<bg=blue;fg=white>                                                         </>",
                "<bg=yellow;fg=black>Next steps</>:",
                "  * Install the site: https://www.drupal.org/docs/8/install",
                "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                "  * Get support: https://www.drupal.org/support",
                "  * Get involved with the Drupal community:",
                "      https://www.drupal.org/getting-involved",
                "  * Remove the plugin that prints this message:",
                "      composer remove drupal/core-project-message"

I just ran composer require 'drupal/admin_toolbar:^3.4' and cleared the cache. Composer says it upgraded admin_toolbar to 3.4 but Drupal reports it's still at 3.3.

  • While you're doing this, it's probably worth considering that having contrib modules in modules/contrib (and custom in modules/custom) is considered best practice. Having them all directly in modules is quite an old style of organising the files as far as Drupal's concerned. It'll still work the way you're doing it (your current issue notwithstanding), but it's going to make things difficult when you want to introduce a proper deployment flow, and less predictable for future devs working on the site
    – Clive
    Commented May 12, 2023 at 19:30
  • That ship has sailed. This site existed pre-v7 (I've forgotten what version we were on originally) and there was no upgrade process that I know of to move modules to the new directories. It was only until when I moved to v9 that things went haywire where some modules were in contrib and some not. We have almost 50 modules and I'd have to uninstall, delete all the settings, and start over from scratch again. And I would have the same problem as above but in reverse. That just isn't feasible. If I'm incorrect, please educate me.
    – Chanel
    Commented May 12, 2023 at 19:44
  • 2
    That's the other thing I should've mentioned - you don't actually need to uninstall a module to move it. Drupal is smart enough to separate the physical path from the module that's installed, it just needs to find a module.info.yml somewhere during discovery to link it up. Usually you would literally move the folder, rebuild cache, then possibly rebuild cache one more time, and all should be well. BTW I realise none of this addresses the error you've got, it was more of an aside. Maybe you could restore a fresh backup, move everything into contrib, clear cache a few times, and see
    – Clive
    Commented May 12, 2023 at 19:48
  • Or if you're not bothered about changing the paths to /contrib, restore a DB backup and just try moving the toolbar module up without uninstalling, and then cache rebuilds
    – Clive
    Commented May 12, 2023 at 19:55
  • 1
    ... and how is the error connected to all of this? This error seems just so random, a wrong callback in a render array. Could be anywhere. Get a stack trace. Xdebug might be helpful to check the variables' content.
    – 4uk4
    Commented May 12, 2023 at 21:18


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.