GoogleApiServiceClient canonical route

Created on 23 May 2024, 7 months ago
Updated 26 August 2024, 4 months ago

Problem/Motivation

The GoogleApiServiceClient class defines a canonical link template but does not actually implement the route. So, if a module attempts to render the canonical route, they will get a "Route "entity.google_api_service_client.canonical" does not exist" exception.

More specifically: a site I'm working on has the Next module installed. There is a hook that runs when an entity is created/updated/deleted that attempts get the canonical URL (here). This issue prevents google_api_service_client entities from being deleted when used with the Next module.

Steps to reproduce

- Create at least one google_api_service_client entity
- Run the following with Drush:

( drush eval "$(cat)" ) <<-'PHP_CODE'
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $storage */
$storage = \Drupal::entityTypeManager()->getStorage('google_api_service_client');
$services = $storage->getQuery()->accessCheck(FALSE)->range(0, 1)->execute();
/** @var \Drupal\google_api_client\GoogleApiServiceClientInterface $client */
$client = $storage->load(array_key_first($services));
try {
  $client->toUrl()->toString(TRUE)->getGeneratedUrl();
}
catch (\Exception $e) {
  print 'Exception caught: ' . $e->getMessage() . PHP_EOL;
}
PHP_CODE

Proposed resolution

Remove the canonical link template

🐛 Bug report
Status

Fixed

Version

4.3

Component

Code

Created by

🇺🇸United States steyep

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024