The Views UI tells you that you can enter a path in the form of node/%/feeds, but doing so while adding a menu tab results in a Fatal error.

Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Some mandatory parameters are missing ("arg_0") to generate a URL for route "view.articles_per_page.page_1".") in "core/themes/classy/templates/navigation/menu-local-task.html.twig" at line 17. in Twig_Template->displayWithErrorHandling() (line 328 of core/vendor/twig/twig/lib/Twig/Template.php).

It works as expected when making the path node/%node/feeds.
The view is accessible in both cases, only the node page that should render the tab blows up.

To reproduce:

  1. Install the standard profile.
  2. Add a content entity reference field to articles and allow pages.
  3. Add a view with a page
    • set the path to node/%/articles
    • set the menu to "menu tab"
    • add a contextual filter with the field added in step 2.
    • add a validation filter: content page bundle
  4. Visit a page content and find a fatal Error

Proposed resolution

fix the bug!

Remaining tasks

User interface changes


API changes

probably not..

Beta phase evaluation

Issue category Bug because it is a functional regression.
Issue priority Major because it is a functional regression, and results in uncaught exceptions
#4 2489940-04-TEST-ONLY.patch4.67 KBjhedstrom
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 113,001 pass(es), 3 fail(s), and 0 exception(s).
[ View ]


catch’s picture

Issue tags:+VDC
catch’s picture

Title:Views path with menu tab» Views path with menu tab does not validate and results in fatal error
jhedstrom’s picture

Assigned:Unassigned» jhedstrom

This can be reproduced without an entity reference field. Adding a simple 'Content ID' argument is enough to throw the exception.

My guess is that views will need to store the menu path with more detail than '%'. Looking into this now.

jhedstrom’s picture

Assigned:jhedstrom» Unassigned
Issue summary:View changes
Status:Active» Needs review
new4.67 KB
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 113,001 pass(es), 3 fail(s), and 0 exception(s).
[ View ]

I haven't been able to figure out the exact fix here, but this is a test that illustrates the fatal error.

Status:Needs review» Needs work

The last submitted patch, 4: 2489940-04-TEST-ONLY.patch, failed testing.

jhedstrom’s picture

In PathPluginBase::getRoute(), this logic:

foreach ($bits as $pos => $bit) {
      if (
$bit == '%') {
// Generate the name of the parameter using the key of the argument
        // handler.
$arg_id = 'arg_' . $arg_counter++;
$bits[$pos] = '{' . $arg_id . '}';
$argument_map[$arg_id] = $arg_id;
      elseif (
strpos($bit, '%') === 0) {
// Use the name defined in the path.
$parameter_name = substr($bit, 1);
$arg_id = 'arg_' . $arg_counter++;
$argument_map[$arg_id] = $parameter_name;
$bits[$pos] = '{' . $parameter_name . '}';

is what allows %node to properly work (route parameter of arg_0 => node), while % fails because it gets assigned to a route parameter (arg_0 => 0) that the routing system doesn't know how to provide.

The last submitted patch, 4: 2489940-04-TEST-ONLY.patch, failed testing.