Drupal\Core\Routing\RouteCompiler::compile($route) assumes that the '$route' object is injected.

Created on 12 August 2019, over 5 years ago
Updated 11 September 2023, about 1 year ago

Problem:
\Drupal\Core\Routing\RouteCompiler::compile($route) generates a \Drupal\Core\Routing\CompiledRoute object but without injecting the '$route' in it. This causes "Notice: Undefined property: Drupal\Core\Routing\CompiledRoute::$route" when the methodes getOptions, getDefaults and getRequirements are called.

The issue can be easily reproduced with enabled 'Devel' module on page devel/php:

$route = new \Symfony\Component\Routing\Route('/');
\Drupal\Core\Routing\RouteCompiler::compile($route)->getDefaults();

Steps to reproduce in Drupal 9

For Drupal 9, devel module has removed the devel/php page so you have to use the devel_php module.

  • Install devel and devel_php modules
  • Login as admin
  • Optional: Enable All messages, with backtrace information -- /admin/config/development/logging
  • Go to /devel/php
  • Paste this code:
    $route = new \Symfony\Component\Routing\Route('/');
    \Drupal\Core\Routing\RouteCompiler::compile($route)->getDefaults();
    
  • Note the error on the page
  • Go to /admin/reports/dblog
  • Note the error in the logs
πŸ› Bug report
Status

Fixed

Version

9.1

Component
RoutingΒ  β†’

Last updated 3 days ago

Created by

πŸ‡§πŸ‡¬Bulgaria rkostov

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024