Problem/Motivation

There was an incorrect change made in #2294157: Switch getOptions() and getRouteParameters() within LocalActionInterface and LocalTaskInterface to use RouteMatch, and now LocalTaskDefault and LocalActionDefault no longer check the actual parameters.
They currently check the raw parameters twice :)

Proposed resolution

Change it
Refactor to remove usage of RouteProvider? Maybe out of scope, but it's how I found the bug.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett created an issue. See original summary.

tim.plunkett’s picture

The last submitted patch, 2: 2912363-params-2-FAIL.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 2: 2912363-params-2-PASS.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
8.29 KB
3.63 KB

Removing less code keeps the tests passing

Status: Needs review » Needs work

The last submitted patch, 5: 2912363-params-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
5.22 KB
5.28 KB

I misunderstood this code completely, whoops!
The RouteMatch passed in is the current route match, not one corresponding to the route being processed.

Without changing the APIs, we can't resolve this confusion. Just fixing the bug now, all other out-of-scope changes should be gone.

Status: Needs review » Needs work

The last submitted patch, 7: 2912363-local-tasks-7.patch, failed testing. View results

tim.plunkett’s picture

Status: Needs work » Needs review

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.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.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

pwolanin’s picture

Status: Needs review » Needs work

Overall looks like a good fix, but a few small fixes would make this great.

Let's rename the variables in the method something like:

  • $parameters -> $route_parameters
  • $raw_variables -> $raw_parameters
  • $variables -> $parameters

Also it would be really helpful to have a code comment explaining when and how it's possible to have a parameter (the upcast value) that's not present in the raw parameters. Tim Plunkett helpfully explained in person that the parameter (variable/slug name) could be in the route defaults and empty, or could be an optional (trailing) slug in the path and in either case the value was populated by a route enhancer.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
4.74 KB
6.36 KB

It makes the patch much less clear, but the resulting code benefits greatly! Thanks for the suggestion

tim.plunkett’s picture

After further in-person discussion, I improved the docs.
Also to prevent any future accidental divergence in these two, I opened #2995138: Refactor duplicate code from LocalActionDefault/LocalTaskDefault and their interfaces into a shared trait/interface

pwolanin’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Looks great, thanks for adding to the code comments and creating the refactor issue.

Since this breaks layouts, making major.

tim.plunkett’s picture

Issue tags: +MWDS2018

#2988970: Layout Builder should make it easier to modify the default layout for an entity type when viewing an entity is the layout issue that is soft-blocked by this issue (we have a hacky workaround for now).

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed a4cedd8c75 to 8.7.x and b53b0daabd to 8.6.x. Thanks!

As a bug fix backported to 8.6.x.

diff --git a/core/lib/Drupal/Core/Menu/LocalActionDefault.php b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
index 246e844a77..5e161ec1de 100644
--- a/core/lib/Drupal/Core/Menu/LocalActionDefault.php
+++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php
@@ -91,8 +91,8 @@ public function getRouteParameters(RouteMatchInterface $route_match) {
     // run, and the route parameters have been upcast. The original values can
     // be retrieved from the raw parameters. For example, if the route's path is
     // /filter/tips/{filter_format} and the path is /filter/tips/plain_text then
-    // $raw_variables->get('filter_format') == 'plain_text'. Parameters that are
-    // not represented in the route path as slugs might be added by a route
+    // $raw_parameters->get('filter_format') == 'plain_text'. Parameters that
+    // are not represented in the route path as slugs might be added by a route
     // enhancer and will not be present in the raw parameters.
     $raw_parameters = $route_match->getRawParameters();
     $parameters = $route_match->getParameters();
diff --git a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php
index ab7cd5ce8d..49a7a2cc68 100644
--- a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php
+++ b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php
@@ -49,8 +49,8 @@ public function getRouteParameters(RouteMatchInterface $route_match) {
     // run, and the route parameters have been upcast. The original values can
     // be retrieved from the raw parameters. For example, if the route's path is
     // /filter/tips/{filter_format} and the path is /filter/tips/plain_text then
-    // $raw_variables->get('filter_format') == 'plain_text'. Parameters that are
-    // not represented in the route path as slugs might be added by a route
+    // $raw_parameters->get('filter_format') == 'plain_text'. Parameters that
+    // are not represented in the route path as slugs might be added by a route
     // enhancer and will not be present in the raw parameters.
     $raw_parameters = $route_match->getRawParameters();
     $parameters = $route_match->getParameters();

Looks like we need to update the code in the comments too. Fixed on commit.

  • alexpott committed a4cedd8 on 8.7.x
    Issue #2912363 by tim.plunkett, pwolanin: LocalTaskDefault/...

  • alexpott committed b53b0da on 8.6.x
    Issue #2912363 by tim.plunkett, pwolanin: LocalTaskDefault/...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.