When trying to understand I got to
<?php
$routes = $this->connection->query("SELECT name, route FROM {". $this->connection->escapeTable($this->tableName) . "} WHERE pattern_outline IN (:patterns) ORDER BY fit", array(
':patterns'=> $ancestors,
))
->fetchAllKeyed();
$collection = new RouteCollection();
foreach ($routes as $name => $route) {
$route = unserialize($route);
if (preg_match($route->compile()->getRegex(), $path, $matches)) {
$collection->add($name, $route);
}
}
?>
this part and asked "weird. Is it possible that preg_match doesn't match? Didn't we already do the matching in SQL? Where is that regexp?". It's dynamically created -- but at the end of the day it's just a string. It must be stored in the router. It's more performant for sure and also saves anyone's sanity who wants to debug a Drupal process from the beginning to the end.