When [content_translation] module is enabled,
And we enable [Custom Permissions],
And we go to "Any people links " or some other links
Then we will get Route "custom_perms_select_list_form" does not exist

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RajabNatshah created an issue. See original summary.

Rajab Natshah’s picture

-

Rajab Natshah’s picture

Issue summary: View changes
Rajab Natshah’s picture

Assigned: Unassigned » Rajab Natshah
Status: Active » Needs work
Rajab Natshah’s picture

Issue summary: View changes
Rajab Natshah’s picture

Issue summary: View changes
Rajab Natshah’s picture

Assigned: Rajab Natshah » Unassigned
josebc’s picture

Priority: Normal » Major
Status: Needs work » Needs review
FileSize
967 bytes

this is related to this change record https://www.drupal.org/node/2306387, issue was a conflict with config_translate module
patch attached

Mohammed J. Razem’s picture

Status: Needs review » Reviewed & tested by the community

Working well.

Rajab Natshah’s picture

Title: When [content_translation] module is enabled, And enabled [Custom Permissions], Then we will get Route "custom_perms_select_list_form" does not exist » When [content_translation, config_translate] module is enabled, And enabled [Custom Permissions], Then we will get Route "custom_perms_select_list_form" does not exist
Rajab Natshah’s picture

Status: Reviewed & tested by the community » Needs work

Works well when we enable the module with the patch after complete installation of the system.

Seems that we will have an issue:
ResponseText: RuntimeException: Recursive router rebuild detected. in Drupal\Core\Routing\RouteBuilder->rebuild() (line 121 of /var/www/html/dev/varbase4c/docroot/core/lib/Drupal/Core/Routing/RouteBuilder.php).

In the installation step of a custom drupal profile
As we do not have any registered route from the Drupal Core yet.

Something wrong in:

class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    $custom_perms = CustomPermsEntity::loadMultiple();
    foreach ($custom_perms as $custom_perm) {
      if ($custom_perm->getStatus()) {
        $paths = $this->configPermsParsePath($custom_perm->getPath());
        foreach ($paths as $path) {
          $path = ($path[0] == '/') ? $path : '/' . $path;
          $url_object = \Drupal::service('path.validator')->getUrlIfValid($path);
          if ($url_object) {
            $route_name = $url_object->getRouteName();
            if ($route = $collection->get($route_name)) {
              $route->setRequirement('_permission', $custom_perm->label());
            }
          }
        }
      }
    }
  }

To Reproduce

Given that we do have the "custom_perms" module in the system
And we added the following: """
- language
- content_translation
- locale
- config_translation
- config_perms
""" to "core/profiles/standard/standard.info.yml" under "dependencies"
When we install Drupal and select "Standard"
Then we will have the issue

So if we have:

   - language
   - content_translation
   - locale
   - config_translation
   - config_perms

In a custom profile, we will have the same issue

josebc’s picture

Not a pretty solution but fixes issue on installation

Rajab Natshah’s picture

Thank you @Jose, It's all your debugging and tracing in the code.
I will use and test in the install.

Rajab Natshah’s picture

Status: Needs work » Needs review

Tested by humans, and robots

Rajab Natshah’s picture

Rajab Natshah’s picture

FileSize
1.88 KB

Updated the patch to work with 8.x-1.1

Rajab Natshah’s picture

Title: When [content_translation, config_translate] module is enabled, And enabled [Custom Permissions], Then we will get Route "custom_perms_select_list_form" does not exist » When [content_translation, config_translate] module are enabled, And enabled [Custom Permissions], Then we will get Route "custom_perms_select_list_form" does not exist
gnuget’s picture

Status: Needs review » Needs work

I just reviewed #12 and I don't think that is the best approach for this.

The problem is that we have a links handler in the entity annotations (See CustomPermsEntity.php) BUT we haven't any route in the routing file nor a route_provider in the entity... so the routes for those links don't exist and that makes this problem.

Accord with [#2306387] we need to provided at least a canonical link, so my proposed solution is:

  • Remove the unused links (there is not an edit/create form) because all is done on the same page.
  • Remove all the no-existent forms in the form handler
  • Create a route_provider and create just the canonical link (which is required by Drupal)
  • Point the canonical link to the route that we created in the route_handler
  • Profit

I'm working on a new branch for this module, which fixes a major problem (see #2894471: Custom Permission for Site Information Page) and there I will fix this as well, would be great if later can you help me to test my fix there.

I will leave a comment when it's done.

Thanks!

gnuget’s picture

Status: Needs work » Needs review

I just pushed a change on the branch 8.x-2.x would be great if you help me to test if that fixes the issue.

Just remember that the branch 8.x-2.x doesn't even have an alpha release yet, so for now just test it in a dev environment.

Thanks!

gnuget’s picture

Does #20 mean that we can close this issue?

😃

Rajab Natshah’s picture

Status: Needs review » Closed (outdated)

Yes, Thank you :)

closing this issue.