Group content entity URI does not include group ID

Created on 1 November 2024, 10 months ago

Problem/Motivation

This issue came to light when using group in combination with the redirect module. When a redirect destination is a group content entity URI in the pattern "entity:group_content/7991", the list of redirects cannot be generated due this error:

Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("group") to generate a URL for route "entity.group_content.canonical". in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 187 of /var/www/docroot/core/lib/Drupal/Core/Routing/UrlGenerator.php)

Moving backwards through the stacktrace reveals that when \Drupal\Core\Url::fromEntityUri is called, the necessary group ID is not retrieved. This makes sense because it is not included in the entity URI. Based on this method, it would appear that a group content entity requiring more than one parameter to generate a URL is fundamentally incompatible with Drupal core. I don't see any way to alter \Drupal\Core\Url::fromEntityUri to make it compatible with the group module.

I know I'm using a very outdated version of the group module. Has the ability to generate a Url object to a group content entity using the entity URI been resolved in a recent version?

Steps to reproduce

  • Create a group content entity.
  • Programmatically call \Drupal\Core\Url::fromUri like this: $url = Url::fromUri('entity:group_content/GROUP_CONTENT_ID')
  • See MissingMandatoryParametersException exception.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.6

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States maskedjellybean Portland, OR

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024