Drupal 8.4.0
LDAP 8.x-3.0-beta3
PHP 7.0.22

I'm able to add servers, but unable to edit servers.

Error output when I try to edit a saved server:

Uncaught PHP Exception Symfony\\Component\\Routing\\Exception\\RouteNotFoundException: "Route "entity.ldap_server.canonical" does not exist." at /site/core/lib/Drupal/Core/Routing/RouteProvider.php line 190, referer: http://site.com/admin/config/people/ldap/server

Function found at line 190 at '/site/main/core/lib/Drupal/Core/Routing/RouteProvider.php':

  /**
   * Find the route using the provided route name (and parameters).
   *
   * @param string $name
   *   The route name to fetch
   *
   * @return \Symfony\Component\Routing\Route
   *   The found route.
   *
   * @throws \Symfony\Component\Routing\Exception\RouteNotFoundException
   *   Thrown if there is no route with that name in this repository.
   */
  public function getRouteByName($name) {
    $routes = $this->getRoutesByNames([$name]);
    if (empty($routes)) {
      throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
    }

    return reset($routes);
  }

Comments

ydahi created an issue. See original summary.

ydahi’s picture

Issue summary: View changes
ydahi’s picture

Issue summary: View changes
ydahi’s picture

A few other notes that may lead to a quicker solution.

Route defined in /site/modules/ldap/ldap_servers/ldap_servers.routing.yml:

entity.ldap_server.edit_form:
  path: '/admin/config/people/ldap/server/{ldap_server}'
  defaults:
    _entity_form: 'ldap_server.edit'
    _title: 'Edit Server'
  requirements:
    _permission: 'administer site configuration'
  options:
    _admin_route: TRUE

Commented-out code in /site/modules/ldap/ldap_servers/src/Entity/Server.php:

/**
 * Defines the Server entity.
 *
 * @ConfigEntityType(
 *   id = "ldap_server",
 *   label = @Translation("LDAP Server"),
 *   handlers = {
 *     "list_builder" = "Drupal\ldap_servers\ServerListBuilder",
 *     "form" = {
 *       "add" = "Drupal\ldap_servers\Form\ServerForm",
 *       "edit" = "Drupal\ldap_servers\Form\ServerForm",
 *       "delete" = "Drupal\ldap_servers\Form\ServerDeleteForm",
 *       "test" = "Drupal\ldap_servers\Form\ServerTestForm",
 *       "enable_disable" = "Drupal\ldap_servers\Form\ServerEnableDisableForm"
 *     }
 *   },
 *   config_prefix = "server",
 *   admin_permission = "administer site configuration",
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "label",
 *     "uuid" = "uuid"
 *   },
 *   links = {
 *     "canonical" = "/admin/config/people/ldap/server/{server}",
 *     "edit-form" = "/admin/config/people/ldap/server/{server}/edit",
 *     "delete-form" = "/admin/config/people/ldap/server/{server}/delete",
 *     "collection" = "/admin/config/people/ldap/server"
 *   }
 * )
 */

$server_edit_path defined on line 274 in /site/modules/ldap/ldap_servers/src/ServerFactory.php:

$server_edit_path = 'admin/config/people/ldap/servers/edit/' . $ldap_server->id();
ydahi’s picture

I was able to hide/fix the problem by deleting line 38 of Server.php which read:

"canonical" = "/admin/config/people/ldap/server/{server}",

The word 'canonical' is only found in three locations within the module:

Searching 134 files for "canonical"

site\modules\ldap\ldap_authentication\ldap_authentication.links.task.yml:
    7    deriver: 'Drupal\ldap_authentication\Plugin\Derivative\DynamicUserHelpLink'
    8    weight: 50
    9:   route_name: entity.user.canonical
   10:   base_route: entity.user.canonical
   11  

site\modules\ldap\ldap_query\src\Entity\QueryEntity.php:
   31   *   },
   32   *   links = {
   33:  *     "canonical" = "/admin/config/people/ldap/query/{ldap_query_entity}",
   34   *     "add-form" = "/admin/config/people/ldap/query/add",
   35   *     "edit-form" = "/admin/config/people/ldap/query/{ldap_query_entity}/edit",

site\modules\ldap\ldap_servers\src\Entity\Server.php:
   36   *   },
   37   *   links = {
   38:  *     "canonical" = "/admin/config/people/ldap/server/{server}",
   39   *     "edit-form" = "/admin/config/people/ldap/server/{server}/edit",
   40   *     "delete-form" = "/admin/config/people/ldap/server/{server}/delete",

4 matches across 3 files

The links array in Server.php now looks like this for me:

 *   links = {
 *     "edit-form" = "/admin/config/people/ldap/server/{server}/edit",
 *     "delete-form" = "/admin/config/people/ldap/server/{server}/delete",
 *     "collection" = "/admin/config/people/ldap/server"
 *   }

I'm new to D8/symphony development so if anyone cares to explain why an array within a comment can be called, I'd appreciate it.

Looking forward to a full fix.

ydahi’s picture

Issue summary: View changes
grahl’s picture

Status: Active » Postponed (maintainer needs more info)

Hi

Could you please retest with latest dev? This sounds more like a misconfiguration on your end. I don't believe we added any improvements to that form since beta3 and the removal you are attempting above is not something we want to do. See also: https://www.drupal.org/docs/8/api/entity-api/creating-a-content-entity-t...

There could be a syntax change from 8.4.0 which could cause this but I cannot reproduce this locally with 8.4.0, latest dev and PHP 7.1.

Please provide additional information on how to reproduce this.

ydahi’s picture

Hi grahl,

I set up a clean Drupal 8.4.0 instance and tested the ldap (8.x-3.0-beta3) module - everything works fine and I am able to edit server definitions.

After installing each of the modules that were on the inflicted site, I think I've found the issue: https://www.drupal.org/project/cancel_button

Steps to reproduce:

- Drupal 8.4.0
- PHP 7
- LDAP 8.x-3.0-beta3
- Entity Form Cancel Button 8.x-1.0

Enabling the cancel button module produces an error when trying to edit a defined server.

A simple workaround is to disable the cancel button for ldap_server pages, which can be done very simply using the cancel_button module's settings.

grahl’s picture

Title: ldap_server: unable to edit saved server conf: ""Route "entity.ldap_server.canonical" does not exist." at /site/main/core/lib/Drupal/Core/Routing/RouteProvider.php line 190," » cancel_button does not work with ldap_servers
Project: Lightweight Directory Access Protocol » Entity Form Cancel Button
Version: 8.x-3.0-beta3 » 8.x-1.0
Status: Postponed (maintainer needs more info) » Active

Thanks for tracking that down.

I'm moving this issue over to cancel_button. If they require a different behavior in ldap_servers and are willing to provide a patch, I'll consider adding it.

norman.lol’s picture

Priority: Normal » Major
grahl’s picture

Status: Active » Closed (works as designed)

This was apparently fixed on our end through the patch provided in #2961668: LDAP configuration entity types define a canonical link template but do not have a canonical route. Apparently we declared a canonical route which didn't exist.

Please reopen if this is still broken for you with latest DEV of ldap.