Problem/Motivation
A Views page fails to load if a module sets the returns_response route option to the string 'false'. ViewPageController::handle() treats the string as true and calls Page::buildResponse(). The Page display plugin, however, has no such method. Core itself sets returns_response to a boolean in PathPluginBase::getRoute(), but a module can override it in a route alter.
Setting _view_display_show_admin_links to 'false' on the same route can leave contextual links enabled. Page::buildBasicRenderable() copies the string into #view_display_show_admin_links, where ContextualLinksHelper::addLinks() treats it as true.
Steps to reproduce
- On a site with the Content view enabled, set
returns_responseto'false'onview.content.page_1in a route alter. Rebuild caches and visit/admin/content/node. The request fails with a call to undefined methodPage::buildResponse(). With nativeFALSE, the page loads. - In
PageTest::testBuildBasicRenderable(), set the_view_display_show_admin_linksroute option to'false'. Inspect#view_display_show_admin_linksin the returned render array. It contains the string'false', which evaluates to true.
Proposed resolution
Use BooleanRouteOption::get() from #3644412: [PP-1] Routing treats "false" as TRUE for _admin_route and no_cache to read returns_response in ViewPageController::handle() and _view_display_show_admin_links in Page::buildBasicRenderable().
In ViewPageControllerTest, verify that a page display with returns_response set to 'false' returns a render array. In PageTest, verify that _view_display_show_admin_links set to 'false' produces boolean FALSE in the render array. In each case, expect a deprecation naming the option.
Remaining tasks
Postponed on #3644412: [PP-1] Routing treats "false" as TRUE for _admin_route and no_cache.
In Drupal 13: Track rejection of deprecated inputs in #3644403: [13.x] Reject deprecated non-boolean input in boolean config values.
User interface changes
None.
API changes
The returns_response and _view_display_show_admin_links Views route options follow the boolean input rules from #3644412: [PP-1] Routing treats "false" as TRUE for _admin_route and no_cache. Use native booleans when altering Views routes in PHP.
Data model changes
None.
Release notes snippet
Views now treats the deprecated string 'false' as FALSE for the returns_response and _view_display_show_admin_links route options.
Issue fork drupal-3644425
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