1

My site has completely gone blank after updating modules with Composer. This is the error I get. I've found some similar errors in a topic from the past, but they are all about earlier version of php and don't help me any further.

Rolling back to earlier version doesn't do anything (php and core), and I have no clue where to look for the problem. Anyone has an idea?

The website encountered an unexpected error. Please try again later.
TypeError: Argument 2 passed to Symfony\Component\Routing\RouteCollection::add() must be an instance of Symfony\Component\Routing\Route, bool given, called in /home/dkvision/staging/website.com/www/core/lib/Drupal/Core/Routing/RouteProvider.php on line 380 in Symfony\Component\Routing\RouteCollection->add() (line 76 of /home/dkvision/staging/website.com/vendor/symfony/routing/RouteCollection.php).

Symfony\Component\Routing\RouteCollection->add('entity.block.edit_form', ) (Line: 380)
Drupal\Core\Routing\RouteProvider->getRoutesByPath('/admin/structure/block/manage/%') (Line: 332)
Drupal\Core\Routing\RouteProvider->getRoutesByPattern('/admin/structure/block/manage/{block}') (Line: 176)
Drupal\devel\Routing\RouteSubscriber->getRouteParameters(Object, 'edit-form') (Line: 87)
Drupal\devel\Routing\RouteSubscriber->getEntityLoadRoute(Object) (Line: 53)
Drupal\devel\Routing\RouteSubscriber->alterRoutes(Object) (Line: 37)
Drupal\Core\Routing\RouteSubscriberBase->onAlterRoutes(Object, 'routing.route_alter', Object)
call_user_func(Array, Object, 'routing.route_alter', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'routing.route_alter') (Line: 189)
Drupal\Core\Routing\RouteBuilder->rebuild() (Line: 83)
Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 120)
Drupal\Core\Routing\Router->matchRequest(Object) (Line: 93)
Drupal\Core\Routing\AccessAwareRouter->matchRequest(Object) (Line: 112)
Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest(Object, 'kernel.request', Object)
call_user_func(Array, Object, 'kernel.request', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.request') (Line: 135)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
7
  • After updating the module files, did you run the database updates? Also, are you using core-recommended for the Symfony components? If not, you should try doing so in order to lock your Symfony deps to known compatible versions. Commented Sep 30, 2022 at 10:46
  • 3
    The issue is caused by the devel module altering routes. I would uninstall the module and check the issue queue. You should not use the devel module in production sites.
    – 4uk4
    Commented Sep 30, 2022 at 11:19
  • @PatrickKenny Yes, I've run the database updates. I don't really know what you mean with your second question, could you clarify? Commented Sep 30, 2022 at 14:33
  • @4uk4 I've removed en reinstalled devel. I don't have this problem on other website (development environment) Got a 500 error now, moved error reporting to the index.php and now this is the error: 'Parse error: syntax error, unexpected '=' in /home/dkvision/staging/equine-law.be/vendor/symfony/string/Resources/functions.php on line 34' Commented Sep 30, 2022 at 14:55
  • For the original error to happen you need also a faulty entity definition. Devel hooks into all different things and Drupal stops on errors that are otherwise not so severe.
    – 4uk4
    Commented Sep 30, 2022 at 15:15

2 Answers 2

1

In Drupal 9, this is caused by route serialization incompatibilities between PHP 7.4 and 7.3.

Suggested steps is to:


If it's still happening, try below steps from this comment.

Truncate the following tables in your database (drush sql-cli):

TRUNCATE TABLE router;
TRUNCATE TABLE  cache_advagg                           ;
TRUNCATE TABLE  cache_bootstrap                        ;
TRUNCATE TABLE  cache_config                           ;
TRUNCATE TABLE  cache_container                        ;
TRUNCATE TABLE  cache_data                             ;
TRUNCATE TABLE  cache_default                          ;
TRUNCATE TABLE  cache_discovery                        ;
TRUNCATE TABLE  cache_dynamic_page_cache               ;
TRUNCATE TABLE  cache_entity                           ;
TRUNCATE TABLE  cache_jsonapi_normalizations           ;
TRUNCATE TABLE  cache_menu                             ;
TRUNCATE TABLE  cache_page                             ;
TRUNCATE TABLE  cache_render                           ;
TRUNCATE TABLE  cache_rest                             ;
TRUNCATE TABLE  cache_schema_metatag_cache             ;
TRUNCATE TABLE  cache_toolbar                          ;
TRUNCATE TABLE  cachetags ;

Rebuild router:

drush ev "\Drupal::service('router.builder')->rebuild()"

Clear cache:

drush cr
1
  • thx this did it. there was no need to manually rebuild the router. drupal did it on page load ;)
    – giorgio79
    Commented Dec 30, 2023 at 20:15
0

This error message indicates that there is an issue with a route definition in your Drupal site. The RouteCollection class in Symfony's routing component is expecting an instance of the Route class as the second argument to its add() method, but it is receiving a boolean value instead. This can happen if there is a problem with the route definition, such as a typo, a missing parameter, or an incorrect syntax.

To troubleshoot this error, here are some steps you can take:

Check the recent changes made to your site's code or configuration that may have affected the routing. This error message is usually caused by a code change, such as adding or modifying a route in a custom module, or updating Drupal or a module to a newer version.

Review the route definition that is causing the error. The error message provides a hint to the location of the problematic code in the RouteProvider.php file, which is part of Drupal's core routing system. This suggests that the issue is likely related to a route defined in your site's code or configuration.

Check the syntax of the route definition. Make sure that the route definition follows the correct syntax and that all required parameters are present. The Symfony routing component has specific requirements for defining routes, such as specifying the path, controller, and any additional requirements or defaults. Refer to the Drupal documentation or Symfony documentation for more information on defining routes.

Check for typos or errors in the code. Make sure that all variables and method calls are spelled correctly and that there are no syntax errors or missing code.

If you are unable to identify the issue, you can try disabling custom modules or themes one by one to isolate the problematic code. Alternatively, you can try rolling back recent changes or restoring a backup of your site to a previous working state.

Once you have identified and resolved the issue, the error message should disappear, and your site should function normally again.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.