Problem/Motivation

ETUF and Linkit modules do not support a different language absolute URL lookup in the different language body field with English language Admin UI .

The linkit throws an exception (UnexpectedValueException Object ( [message:protected] => External URLs do not have internal route parameters. )

The same case happens when the admin switches the Admin UI from English to French. The ETUF and linkit cannot fail to match an English absolute URL in the English body field as an internal entity under French language Admin UI.

lookup_failure

Steps to reproduce

Assuption: The Drupal site suppport English and French languages.

1) Create a testing landing page B with English & French contents.
2) Create a testing landing page C with English & French contents
Published the page C with absolute URLs
http://www.localhost/en/drupal/testinglandingpagec
http://www.localhost/fr/drupal/testinglandingcfrenchpage
3) Edit the French body field of the landing page B with English language Admin UI.
4) Create a link to point the French landing page C with its absolute URL (http://www.localhost/fr/drupal/testinglandingcfrenchpage)

As the results, the linkit module fails to match the URL with a node entity (the French landing page C).

The line $params = Url::fromUserInput($user_input)->getRouteParameters() of the function findEntityIdByUrl($user_input) in EntityMatcher.php throws the error below.

UnexpectedValueException Object ( [message:protected] => External URLs do not have internal route parameters. 
[string:Exception:private] => [code:protected] => 0 [file:protected] => /html/core/lib/Drupal/Core/Url.php [line:protected] => 583 
[trace:Exception:private] => Array ( [0] => Array ( [file] => /html/modules/contrib/linkit/src/Plugin/Linkit/Matcher/EntityMatcher.php 
[line] => 583 [function] => getRouteParameters [class] => Drupal\Core\Url [type] => -> ) [1] => 
Array ( [file] => /d8x/aol/html/modules/contrib/linkit/src/Plugin/Linkit/Matcher/EntityMatcher.php [line] => 348 
[function] => findEntityIdByUrl [class] => Drupal\linkit\Plugin\Linkit\Matcher\EntityMatcher [type] => -> ) [2] => 
Array ( [file] => /html/modules/contrib/linkit/src/SuggestionManager.php [line] => 36 [function] => execute 
[class] => Drupal\linkit\Plugin\Linkit\Matcher\EntityMatcher [type] => -> ) [3] => 
Array ( [file] => /html/modules/contrib/linkit/src/Controller/AutocompleteController.php [line] => 91 
[function] => getSuggestions [class] => Drupal\linkit\SuggestionManager [type] => -> ) [4] => 
Array ( [function] => autocomplete [class] => Drupal\linkit\Controller\AutocompleteController [type] => -> ) [5] => 
Array ( [file] => /html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php [line] => 123 
[function] => call_user_func_array ) [6] => Array ( [file] => /d8x/aol/html/core/lib/Drupal/Core/Render/Renderer.php [line] => 564 
[function] => Drupal\Core\EventSubscriber\@closure [class] => Drupal\Core\EventSubscriber\EarlyRenderingControll

Proposed resolution

Change the logic of the statement (Url::fromUserInput($user_input, $options)->getRouteParameters() of the function findEntityIdByUrl in EntityMatcher.php

    try {
      $params = Url::fromUserInput($user_input, $options)->getRouteParameters();
      if (!empty($params[$this->targetType])) {
        $result = [$params[$this->targetType]];
      }
    }
    catch (Exception $e) {
      // Do nothing.
    }

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
ETFUandLinkit_fails_lookup.png56.85 KBjamesyao

Comments

jamesyao created an issue. See original summary.

joseph.olstad’s picture

Issue summary: View changes