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

  1. On a site with the Content view enabled, set returns_response to 'false' on view.content.page_1 in a route alter. Rebuild caches and visit /admin/content/node. The request fails with a call to undefined method Page::buildResponse(). With native FALSE, the page loads.
  2. In PageTest::testBuildBasicRenderable(), set the _view_display_show_admin_links route option to 'false'. Inspect #view_display_show_admin_links in 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

Command icon 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

pancho created an issue.