Problem/Motivation

Migrating from a drupal 6 site and get this error:

[error] The internal path component 'https://example.com/publications.html' is external. You are not allowed to specify an external URL together with internal:/.''

Which is coming from MenuLinkParent because of the assumption that the parent link path is routeable through $url = Url::fromUserInput("/$parent_link_path");

Proposed resolution

Check for external and search for the link uri properties.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joelpittet created an issue. See original summary.

joelpittet’s picture

Status: Active » Needs review
Issue tags: +migrate-d6-d8
FileSize
1.94 KB
quietone’s picture

Assigned: Unassigned » quietone

Assigning to myself for rvw

quietone’s picture

I have a look at this and it only raised questions. MenuLinkParent should be handling external links, but the parent issue already handle external parents, admittedly that did not fix the error that joelpittet was having. Still, it makes more sense to me to report the error there and improve that issue. It doesn't help that I don't know much about menu link either.

Second opinion anyone? Merge this into the parent or not?

quietone’s picture

Assigned: quietone » Unassigned

Unassigning

joelpittet’s picture

@quietone, Thank you for the review! The parent issue seemed to have a wider "task"/refactor scope to it, I created this to keep the scope to the bug as to not confuse the two issues. Though this will force a reroll as they touch a bit of the same code.

quietone’s picture

Assigned: Unassigned » quietone

Assigning to self for review

quietone’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Discussed at a migrate meeting and there is no problem adding this separately from the parent issue. However, this does need tests.

quietone’s picture

Assigned: quietone » Unassigned

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mikelutz’s picture

Status: Needs review » Needs work
Issue tags: -migrate-d6-d8 +needs backport to 8.7.x, +Seattle2019

Looking really good. Only one little nit.

+++ b/core/modules/migrate/tests/src/Unit/process/MenuLinkParentTest.php
@@ -35,4 +36,25 @@ public function testTransformException() {
+  /**
+   * @covers ::transform
+   */

Needs a short comment here "Test plugin when the parent is an external link"

heddn’s picture

Status: Needs review » Reviewed & tested by the community

All feedback addressed and tests added.

idebr’s picture

Status: Reviewed & tested by the community » Needs work

The patch in #15 caused my migration to fail:

In MenuLinkManager.php line 207:

  Plugin ID '9054' was not found.
  1. +++ b/core/modules/migrate/src/Plugin/migrate/process/MenuLinkParent.php
    @@ -85,17 +86,28 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
    +      $links = [];
    +      if (UrlHelper::isExternal($parent_link_path)) {
    +        $loaded = $this->menuLinkStorage->loadByProperties(['link__uri' => $parent_link_path]);
    +        foreach ($loaded as $plugin_id => $definition) {
    +          $links[$plugin_id] = $this->menuLinkManager->createInstance($plugin_id);
    +        }
    +      }
    

    This change is incorrect:$loaded is keyed by entity id, not plugin id:

      /**
       * Load entities by their property values.
       *
       * @param array $values
       *   An associative array where the keys are the property names and the
       *   values are the values those properties must have.
       *
       * @return \Drupal\Core\Entity\EntityInterface[]
       *   An array of entity objects indexed by their ids.
       */
      public function loadByProperties(array $values = []);
    
  2. +++ b/core/modules/migrate/tests/src/Unit/process/MenuLinkParentTest.php
    @@ -35,4 +36,27 @@ public function testTransformException() {
    +    $menu_link_storage->loadByProperties([
    +      'link__uri' => 'http://example.com',
    +    ])->willReturn([
    +      'external_example_plugin_id' => [],
    +    ]);
    

    Menu link content id is numeric (eg. 9054), while a plugin_id looks like ‌menu_link_content:fe151460-dfa2-4133-8864-c1746f28ab27

idebr’s picture

Attached patch contains the following changes:

  1. Updated \Drupal\Tests\migrate\Unit\process\MenuLinkParentTest: $menu_link_storage will now return MenuLinkContentInterface[]
  2. \Drupal\migrate\Plugin\migrate\process\MenuLinkParent::transform: simplified $links variable similar to the current call to the current $this->menuLinkManager->loadLinksByRoute

The last submitted patch, 18: 2968170-18-test-only.patch, failed testing. View results

Lendude’s picture

Status: Needs review » Reviewed & tested by the community

Changes in #18 look good and make sense.

#17 sounds like an integration level test might be good for this, but the Unit tests seem to be the standard for these migration classes, so I guess this is sufficient.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 18: 2968170-18.patch, failed testing. View results

Lendude’s picture

Status: Needs work » Reviewed & tested by the community

Unrelated fail in MediaLibraryTest

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 18: 2968170-18.patch, failed testing. View results

Lendude’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 18: 2968170-18.patch, failed testing. View results

yogeshmpawar’s picture

Status: Needs work » Reviewed & tested by the community

All looks good so setting back to RTBC! Tests failure is not related (see #3055648: Frequent random fail in \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTest).

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 18: 2968170-18.patch, failed testing. View results

heddn’s picture

Status: Needs work » Reviewed & tested by the community

The last submitted patch, 18: 2968170-18-test-only.patch, failed testing. View results

The last submitted patch, 18: 2968170-18-test-only.patch, failed testing. View results

heddn’s picture

Re-uploading #18 as a new patch so we don't keep having test runs (and failures) on the test only patch.

alexpott’s picture

Crediting @quietone for issue review and @mikelutz and @tim.plunkett as per #12.

alexpott’s picture

Version: 8.8.x-dev » 8.7.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: -needs backport to 8.7.x

Committed and pushed 296ba5d866 to 8.8.x and f21ee89c72 to 8.7.x. Thanks!

  • alexpott committed 296ba5d on 8.8.x
    Issue #2968170 by joelpittet, idebr, heddn, quietone, mikelutz, tim....

  • alexpott committed f21ee89 on 8.7.x
    Issue #2968170 by joelpittet, idebr, heddn, quietone, mikelutz, tim....

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.