Problem/Motivation

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

no

API changes

probably not..

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because it is a functional regression.
Issue priority Major because it is a functional regression, and results in uncaught exceptions
Files: 

Comments

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
FileSize
4.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.

xjm’s picture

The core committers and Views maintainers (alexpott, xjm, effulgentsia, tim.plunkett, and dawehner) agreed that this is a major issue. This is a very common usecase and an exception is being thrown potentially on a lot of user-facing pages when the site builder follows the instructions in the Views UI. The issue is not critical because there is a workaround (using the named argument) and no actual data loss.

xjm’s picture

Issue tags: +Triaged D8 major

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Lendude’s picture

Status: Needs work » Needs review
Issue tags: -views
FileSize
4.69 KB

This is still a problem. Test only patch didn't apply anymore, rerolled.

Status: Needs review » Needs work

The last submitted patch, 11: 2489940-11-TEST_ONLY.patch, failed testing.

Lendude’s picture

Status: Needs work » Needs review
FileSize
1.21 KB
6.03 KB

Stab at a fix for this. Not sure if this is the best way to go but it turns the test green so that's something.

Status: Needs review » Needs work

The last submitted patch, 13: menu_path_wildcard-2489940-13.patch, failed testing.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

sathish.redcrackle’s picture

FileSize
6.17 KB

I have modified the patch file. Now the test will get passed.