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;
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 2725081-13.patch | 3.11 KB | quietone |
| #13 | 2725081-13-fail.patch | 2.43 KB | quietone |
| #10 | 2725081-10.patch | 2.53 KB | quietone |
| #10 | 2725081-10-fail.patch | 1.85 KB | quietone |
Comments
Comment #2
generalredneckComment #3
mikeryanNote the related issue #2565931: Handle long comment bundle names. Also note the dedupe_entity process plugin, which should be part of the solution.
Comment #6
mikeryanComment #7
heddnComment #8
heddnAdding the dedupe process plugin into the taxonomy yaml files is definitely a novice task. Flagging.
Comment #9
quietone commentedD6 migration already dedupes the machine name and tests for names longer than 32 characters.
Comment #10
quietone commentedComment #13
quietone commentedRight, change the entity count.
Comment #15
heddnYup, this fixes it. There's tests. We're using the right process plugins. Looks good.
Comment #16
gábor hojtsyComment #19
gábor hojtsyThanks, verified that the D6 migration is already using this plugin with the same setup.
Comment #20
gábor hojtsyShould end up in 8.3.x where it was backported :)