Migrate empty, <nolink> and <none> link field

Created on 30 January 2020, about 5 years ago
Updated 7 March 2025, 26 days ago

Problem/Motivation

User can use route:<nolink> to create no-link links (see #2693725: Add to allow for non-link links ). However, D8 migration does not handle empty URI, and properly. They are skipped.

Proposed resolution

Add support for migrating empty URI, <nolink>, <none> into route:<nolink> to create no-link links.

As <front> is a special migration case, so should be these.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None

🐛 Bug report
Status

Fixed

Version

8.9 ⚰️

Component

migration system

Created by

🇲🇾Malaysia ckng

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada joelpittet Vancouver

    Not a huge deal, but links meant to be external-only are getting and can’t be saved.

    I just extended the functionality and added a revert to handle it. 🚀

    use Drupal\link\Plugin\migrate\process\FieldLink as DrupalFieldLink;
    use Drupal\migrate\Attribute\MigrateProcess;
    
    #[MigrateProcess('my_field_link')]
    final class FieldLink extends DrupalFieldLink {
    
      protected function canonicalizeUri($uri) {
        $uri = parent::canonicalizeUri($uri);
        if ($uri === 'route:<nolink>') {
          return '';
        }
    
        return $uri;
      }
    }
    

    Not sure how to check if external only is on the field settings, but this works to get the migration done

  • 🇺🇸United States mikelutz Michigan, USA

    Not a huge deal, but links meant to be external-only are getting and can’t be saved.

    This should probably be a new issue, I'd like to explore this a bit. We may want to add a 'allow empty' option or something, but I'd need to see some tests (and go back and look at D7) to see how we could get ourselves into a situation with a blank external only uri and what happens in the migration.

Production build 0.71.5 2024