Problem/Motivation
An HTML route under /admin can opt out of admin treatment with _admin_route: false. If a module writes _admin_route: 'false', AdminContext::isAdminRoute() returns TRUE and DenyAdminRoutes::check() denies dynamic page caching.
The same happens with no_cache: 'false'. DenyNoCacheRoutes::check() denies caching because PHP treats the non-empty string 'false' as true.
Steps to reproduce
- Enable Block. In the
#[Route]attribute onBlockController::demo(), setoptions: ['_admin_route' => 'false', 'no_cache' => 'false']and rebuild caches. - Open the block region demonstration page for an installed theme. On this route (
block.admin_demo),AdminContext::isAdminRoute()returnsTRUEandDenyNoCacheRoutes::check()returnsDENY. - Set both options to the boolean
FALSEand rebuild caches. The same calls now returnFALSEandNULL, respectively.
Proposed resolution
Apply the boolean input rules from #3644386: "false" is interpreted as TRUE in boolean configuration to both route options, including values supplied in PHP. Interpret 'false' as FALSE and report a deprecation naming the route option. Preserve the existing fallback for unrecognized input during the deprecation period.
Cover all Core readers, including ContentTranslationRouteSubscriber::alterRoutes(). Test each option independently. Also test that omitting _admin_route on an HTML route under /admin still gives the route its default admin status.
API changes
Use unquoted booleans in *.routing.yml and native booleans in PHP. The exact values 0, 1, '0' and '1' remain accepted without a deprecation.
Release notes snippet
The route options _admin_route and no_cache now treat 'false' as FALSE and deprecate the quoted value.
Issue fork drupal-3644412
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments