Steps to reproduce:

Create a Taxonomy Vocabulary in Drupal 7 that has a machine name longer than 32 chracters
Run Migrate upgrade against that drupal 7 site.

Note the error thrown by entitymanager:

Attempt to create a bundle with an ID longer than 32 characters: ().
(/var/www/html/build/core/lib/Drupal/Core/Entity/Entity.php:402)

I expect us to handle these cases in some fashion since machine names cannot be changed after created... maybe by taking thee first 30 chracters and then running the machine name through dedup so that it takes something like "my_extreamly_long_taxonomy_vocabulary_name" and "my_extreamly_long_taxonomy_vocabulary_fame" and turns it into "my_extreamly_long_taxonomy_voc_1", "my_extreamly_long_taxonomy_voc_2" respectively.

My current solution (which doesn't dedup) to this was to create a custom source plugin that extends the existing and do a substring(1,32) on machine_name and change the configuration to work with this using Migrate Plus and Migrate Tools.

namespace Drupal\wg_drupal7_migrate\Plugin\migrate\source;

use Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary as MigrateD7Vocabulary;

/**
 * Drupal 7 vocabularies source from database.
 *
 * @MigrateDrupalSource(
 *   id = "wg_d7_taxonomy_vocabulary",
 *   source_provider = "taxonomy"
 * )
 */
class Vocabulary extends MigrateD7Vocabulary {
  /**
   * {@inheritdoc}
   */
  public function query() {
    $query = $this->select('taxonomy_vocabulary', 'v')
      ->fields('v', array(
        'vid',
        'name',
        'description',
        'hierarchy',
        'module',
        'weight',
      ));
    $query->addExpression('SUBSTRING(machine_name, 1, 32)', 'machine_name');
    return $query;
  }
}

Comments

generalredneck created an issue. See original summary.

generalredneck’s picture

Title: pervious versions of Drupal allow Vocabulary Machine Names larger than 32 chracters » pervious versions of Drupal allow Vocabulary Machine Names larger than 32 characters
mikeryan’s picture

Note the related issue #2565931: Handle long comment bundle names. Also note the dedupe_entity process plugin, which should be part of the solution.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.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.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mikeryan’s picture

Issue tags: +migrate-d6-d8, +migrate-d7-d8
heddn’s picture

Title: pervious versions of Drupal allow Vocabulary Machine Names larger than 32 characters » Previous versions of Drupal allow Vocabulary Machine Names larger than 32 characters
heddn’s picture

Issue tags: +Novice

Adding the dedupe process plugin into the taxonomy yaml files is definitely a novice task. Flagging.

quietone’s picture

Issue tags: -migrate-d6-d8

D6 migration already dedupes the machine name and tests for names longer than 32 characters.

quietone’s picture

Status: Active » Needs review
StatusFileSize
new1.85 KB
new2.53 KB

The last submitted patch, 10: 2725081-10-fail.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 10: 2725081-10.patch, failed testing.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new2.43 KB
new3.11 KB

Right, change the entity count.

The last submitted patch, 13: 2725081-13-fail.patch, failed testing.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

Yup, this fixes it. There's tests. We're using the right process plugins. Looks good.

gábor hojtsy’s picture

Title: Previous versions of Drupal allow Vocabulary Machine Names larger than 32 characters » Previous versions of Drupal allow vocabulary machine names longer than 32 characters
Version: 8.3.x-dev » 8.4.x-dev

  • Gábor Hojtsy committed bc745b7 on 8.4.x
    Issue #2725081 by quietone: Previous versions of Drupal allow vocabulary...

  • Gábor Hojtsy committed dfd7cdc on 8.3.x
    Issue #2725081 by quietone: Previous versions of Drupal allow vocabulary...
gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, verified that the D6 migration is already using this plugin with the same setup.

gábor hojtsy’s picture

Version: 8.4.x-dev » 8.3.x-dev

Should end up in 8.3.x where it was backported :)

Status: Fixed » Closed (fixed)

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