Problem/Motivation

The taxonomy page is now a view, so visiting /taxonomy/term/X will use a view to display the list. This view may be modified to use optional arguments as it was before #1857256: Convert the taxonomy listing and feed at /taxonomy/term/%term to Views where the view used a term_node_tid_depth argument instead of a single tid argument. That modifies the path under the route. However content translation is not ready to fill in route parameters other than the default entity identifier expected, so such modifications in the path under the route result in fatal errors from content translation:

Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "arg_1" for route "/taxonomy/term/{taxonomy_term}/{arg_1}/translations" must match "[^/]++" ("" given) to generate a corresponding URL. in Symfony\Component\Routing\Generator\UrlGenerator->doGenerate() (line 167 of core/vendor/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php).

Proposed resolution

We should inherit route parameters in the content translation routes from the canonical route for this use case.

Remaining tasks

Devise fix
Write tests
Reviews

User interface changes

None.

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Gábor Hojtsy’s picture

Issue tags: +sprint

This seems to be all down to ContentTranslationRouteSubscriber only assuming the entity_type_id (in this case taxonomy_term) parameter on the route instead of copying over all the route parameters from the base route. Theoretically that should not be too hard to resolve (famous last words).

jhodgdon’s picture

Why does it only affect the view and not the default term listing?

Gábor Hojtsy’s picture

The default route for taxonomy terms is (from taxonomy.routing.yml):

entity.taxonomy_term.canonical:
  path: '/taxonomy/term/{taxonomy_term}'

On the other hand, the view has a depth argument which is added on the path (but has a default value, so is optional):

/taxonomy/term/{taxonomy_term}/{arg_1}

(Quoted from your error message, generated in core/modules/views/src/Plugin/views/display/PathPluginBase.php) See also the path pattern for the feed attached to the taxonomy term view (in core/modules/taxonomy/config/install/views.view.taxonomy_term.yml):

path: taxonomy/term/%/%/feed

Views is relying on a trick here that now the same route can be replaced with a different route that may have more arguments. The tabs are route-associated, so we can still put a tab that is not technically on the same path level even if the taxonomy term page uses a depth argument, we just need to inherit the route arguments in the ContentTranslationRouteSubscriber instead of assuming only the entity type one exists.

jhodgdon’s picture

Ah, OK.

So to fix it, you're saying that in ContentTranslationRouteSubscriber where it is setting up the new Route(), we just need to add some more to the defaults array if there are additional arguments? That seems like an easy fix. Let's see...

I tried this (see attached patch). It does add 'arg_1' to the defaults... but the same error still occurs, and actually I think the path for translations shouldn't have the /{arg_1} in it, right? I don't think we want the path to use for translations to change, just because we've enabled this view, do we?

jhodgdon’s picture

Title: Taxonomy term view has fatal error with Language module enabled » Taxonomy term view has fatal error with Content Translation module enabled

Fixing title...

Gábor Hojtsy’s picture

Status: Active » Needs review

@jhodgdon: Yeah that is exactly what I had in mind.

As for how we should tie to the original path, we ask the entity type for the canonical route and this is what we get. How else can we get the non-views path if the route given by the entity info is already altered? (I believe views alters the route but leaves the entity info alone).

      if (!$entity_route = $collection->get($entity_type->getLinkTemplate('canonical'))) {
jhodgdon’s picture

Status: Needs review » Needs work

I have no idea how to get the non-altered route.

So just to be clear, that patch I uploaded doesn't actually work -- the Taxonomy view still has a fatal error with Content Translation enabled. I just uploaded it so you could see what I was trying to do. It accomplishes the goal of adding the default to the Route constructor, but that doesn't fix the bug.

We should probably write a test for this too -- steps to reproduce are in the issue summary.

jibran’s picture

Assigned: Unassigned » jibran

Writing some test.

jibran’s picture

Assigned: jibran » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
3.94 KB

Thanks for the steps @jhodgdon. This is test only patch.

Status: Needs review » Needs work

The last submitted patch, 10: 2324809-test-only.patch, failed testing.

jibran’s picture

Status: Needs work » Closed (duplicate)

See #1857256-165: Convert the taxonomy listing and feed at /taxonomy/term/%term to Views fixes this bug. I am going to add these test there.

Gábor Hojtsy’s picture

Title: Taxonomy term view has fatal error with Content Translation module enabled » If entity canonical path is overridden with a view with optional arguments, content translation's routes will result in fatal errors
Component: taxonomy.module » content_translation.module
Priority: Critical » Normal
Issue summary: View changes
Status: Closed (duplicate) » Needs work
Issue tags: -sprint

I see #1857256: Convert the taxonomy listing and feed at /taxonomy/term/%term to Views resolves the fatal from by removing the depth argument currently in the view (but that is not THE reason to remove the depth argument, so yay for yet another good side effect), but this issue is not resolved for the case when someone does want to do that or override other entity pages with views that may have more dynamic arguments. So I think this is still worth reopening on a lower priority level. Updated issue summary for that.

dawehner’s picture

OH I see, yeah there are several problems here
What could help you here is #2285413: [Meta] Standardize entity route names, let me explain why.
This issue on the long run plans to replace the link templates to be paths again. This means that the routes
for content translation as well as config translation, would rely on that path information. So your generated routes will look like taxonomy/{taxonomy_term}/translate. In case you worry, the routing system always prefer non-placeholders in the path against placeholders.

jhodgdon’s picture

The taxonomy listing is now using Views; the original issue here is obsolete due to #1857256: Convert the taxonomy listing and feed at /taxonomy/term/%term to Views... Needs issue summary update if this issue is to stay open, and I don't think this is really about D8MI any more is it?

Gábor Hojtsy’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Updated. It is still a D8MI issue because this would be a problem with the route added by content_translation module on top of a route that Views modified from the original.

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.

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.

andypost’s picture

+++ b/core/modules/content_translation/src/Routing/ContentTranslationRouteSubscriber.php
@@ -53,12 +53,24 @@ protected function alterRoutes(RouteCollection $collection) {
+        // Skip defaults if they start with _ or if we have already defined
+        // them.

Comment should tell why they skipped

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.

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

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.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.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

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

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

longwave’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce, +Bug Smash Initiative

Discussed with @Lendude in #bugsmash triage.

The IS is brief and not entirely clear; what would be helpful here is someone figuring out how to reproduce the issue since the direction changed in #13, and either writing down the steps or exporting the view that causes the bug.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Since there hasn't been a follow up to #29 going to close out for now.

If still a bug for D10+ please reopen updating issue summary with steps to reproduce

Thanks all!