I have a Drupal 6 site with a taxonomy vocabulary that has a system name called "type".
When I try to migrate the site to Drupal 8 the migration fails with errors.
Upgrading d6_vocabulary_field
Attempt to create field storage type which is reserved by entity type node.
(/core/modules/field/src/Entity/FieldStorageConfig.php:321)
Upgrading d6_vocabulary_field_instance
Attempt to create a configurable field of non-configurable field storage type.
(/core/modules/field/src/Entity/FieldConfig.php:289)
Upgrading d6_term_node:4
Illegal offset type in isset or empty EntityFieldManager.php:289 [warning]
Illegal offset type EntityFieldManager.php:305 [warning]
Illegal offset type EntityFieldManager.php:307 [warning]
Invalid argument supplied for foreach() ContentEntityBase.php:521 [warning]
PHP Fatal error: Call to a member function getFieldStorageDefinition() on a non-object in */core/lib/Drupal/Core/Entity/ContentEntityBase.php on line 1102
The cause seems to be in FieldStorageConfig.php:321
// Disallow reserved field names.
$disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->getTargetEntityTypeId()));
if (in_array($this->getName(), $disallowed_field_names)) {
throw new FieldException("Attempt to create field storage {$this->getName()} which is reserved by entity type {$this->getTargetEntityTypeId()}.");
}
So a fieldname "type" is not allowed and when in Drupal 6 a vocabulary is called "type" the migration goes seriously wrong with random WSOD's on nodes caused by wrong storage of the nodes in the database. It looks like all the field data of a node has shifted one column.
There should somewhere be a solution for this because when I try it on a vanilla Drupal 8 site I can make a vocabulary that is called "type".
Comment | File | Size | Author |
---|---|---|---|
#34 | 2854878-34-reroll-30.patch | 23.02 KB | joelpittet |
#30 | interdiff.txt | 4.37 KB | quietone |
#30 | 2854878-30.patch | 22.93 KB | quietone |
#29 | interdiff-27-29.txt | 18.14 KB | maxocub |
#29 | 2854878-29.patch | 23.37 KB | maxocub |
Comments
Comment #2
hansrossel CreditAttribution: hansrossel commentedComment #3
hansrossel CreditAttribution: hansrossel commentedI changed now the name of the vocabulary to "het type" and the migrated site seems ok, the vocabulary is imported and terms are assigned to the nodes, but there are still some errors:
and
Comment #4
mikeryanYep - because we create the taxonomy reference fields without a "field_" prefix, they can conflict with base fields like type, title, ... - I'm surprised there haven't been more reports of this. Here's a quick POC patch which prepends field_ to the reference field names, running through the testbot to see what fails there (hopefully only tests expecting the non-prepended names) then we'll set back to "Needs work".
Obviously we'll need to add tests. Also, in place of a simple truncation of the constructed field name we should run it through make_unique_entity_field to make sure we aren't creating conflicts against other fields (e.g., in the OP if there were a 'field_type' in D6). Simple enough to do in the d6_vocabulary_field.yml file, but how do the other pieces know what field name was ultimately generated?
Since this causes data loss in the straight upgrade scenario, upgrading the priority.
Comment #6
mikeryanEncouraging that it looks like the only failures were tests using the field names without 'field_'...
Comment #8
jofitz CreditAttribution: jofitz at ComputerMinds commentedI'm confused by these test results - which test is failing?
Comment #9
mikeryanYeah, it's strange, need to look at the full log to find:
15:19:58 Drupal\migrate_drupal_ui\Tests\d6\MigrateUpgrade6Test 622 passes 2 fails
I'll try running that test locally...
Comment #10
mikeryanSo, my changes seem to be preventing one of the term reference fields from being created.
Comment #11
mikeryanComment #12
maxocub CreditAttribution: maxocub commentedThe test was failing because the field 'field_tags' is already provided by standard, so the migrated field 'tags' is renamed to 'field_tags' and the entity count for field_config and field_storage_config gets lowered by one. Let's see if this passes.
Comment #14
phenaproximaCan we add a comment explaining that raw_field_name is only used further down in the processing pipeline, and otherwise essentially thrown out?
The fact that this is repeated suggests to me that this "transform to a field name" stuff should be its own process plugin, living in Migrate Drupal.
If you change any assertIdentical() calls, please change them to assertSame() while you're at it.
Comment #15
maxocub CreditAttribution: maxocub commentedRe #12:
1) Added the comment.
2) This does not seem absolutely necessary, so we agreed to let this goes.
3) This too is not absolutely necessary, and it would create a lot of unrelated noise in this patch.
Comment #16
joelpittetre #15.3, it looks like this was already done in the patch, there are issues already dealing with that, #2756519: Convert assertIdentical() to assertSame() for some uses in kernel tests that already have assertSame()'s parameter order just make sure new assertions use
assertSame()
(there are none, btw) and leave existing assertions alone, also the parameter order is different betweenassertSame
andassertIdentical
, so this change also causes more work/noise.Comment #17
joelpittetAsked @maxocub on IRC if I could tackle this. It looks RTBC to me otherwise.
Comment #18
joelpittetFYI this is conflicting with #2754787: d6_term_node migration overwrites node changed timestamps
It shouldn't be but the context lines are close so it should be easy to re-roll either.
Comment #19
quietone CreditAttribution: quietone as a volunteer commentedThe reduction of the entity count in MigrateUpgradeTest is unexpected but well explained in #12.
Just noticed that a comment is a bit repetitive.
The second sentence isn't really necessary. After all, the first sentence states it is *only* used in the pipeline. Note that this comment appears in other migrations as well.
Comment #20
maxocub CreditAttribution: maxocub commentedGood catch.
Comment #21
joelpittetMy changes were trivial in #17. This looks to be the correct approach to deal with name conflicts.
Comment #22
maxocub CreditAttribution: maxocub commentedComment #23
catchThe changes in the patch look good, but we don't have test explicit coverage for migrating a taxonomy vocabulary conflicting with the name of a base field, which was the original bug report, I think that's worth adding so CNW for that.
Comment #24
maxocub CreditAttribution: maxocub commentedHere's new tests whit a D6 vocabulary named 'Type'. The test-only patch (which also serve as the interdiff) should generate the same error as in the IS.
Comment #27
maxocub CreditAttribution: maxocub commentedForgot to update the entity count...
Comment #28
quietone CreditAttribution: quietone as a volunteer commentedYes, this look good. I loaded up the test fixture and it is still good. Ran a full migration, just with the test fixture, and confirmed this fixes the problem in the IS.
However, I do agree with comments #14.2 that the repetitive code in the migration should be in a process plugin and #14.3 that the assertIdenticals should be changed to assertSame. How about a followup to look into the process plugin. And for the later, maybe I can get to it tomorrow. I don't want to hold up a critical, but there are plenty of RTBC issues waiting for attention.
Comment #29
maxocub CreditAttribution: maxocub commentedRe #14.3: I changed all assertIdentical() to assertSame().
Re #14.2: Despite the fact that it was phenaproxima who suggested to make a process plugin to avoid code duplication, he also agreed (in person in a sprint in Montreal and in a Migrate meeting on hangout) that it was not that usefull in the end. As you can see in this latest patch, the process plugin is quite small. I already hear people asking if a process plugin that small is really usefull, since it's just doing concat & substr.
I did it anyway, for demonstration purpose, and if you think it is in fact better, then we'll need to add documentation & tests.
Comment #30
quietone CreditAttribution: quietone as a volunteer commented@maxocub, thanks for that. I think we've had a miscommunication about the process plugin. I just meant that it could be looked at in a follow up, not done here. And I do see that it is a tiny function. I also thought it was used elsewhere in core and now that I have looked I only see one case. And that one case I wrote, so maybe it was just on my mind as something useful.
I've removed the process plugin since it was error and even though I won't be able to RTBC this.
Comment #31
maxocub CreditAttribution: maxocub commented@quietone: No problem, I did it here because it wasn't that hard and to have a choice between these two options. I understand that my comment in #15 was not clear why this process plugin idea was not pursued.
Comment #32
joelpittetThat
field_name_prefix
process plugin wasn't necessary but cleaned up the duplication a bunch, I think a follow-up for that would be nice.Comment #33
catchNeeds a re-roll for 8.4.x/8.5.x
I'm fine with the duplication in YAML here for the moment, we can look at the specific plugin in a follow-up, but it's also good to have examples on where it's not necessary to write one.
Comment #34
joelpittetComment #36
joelpittetI diffed the diffs, it's only context lines in /MigrateUpgrade6Test.php that failed and just a bit of fuzz for patch command, so re-RTBC.
Comment #38
joelpittetComment #42
catchCNW was due to not applying to 8.3.x, which is the point of the re-roll..
Committed/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!
Comment #44
maxocub CreditAttribution: maxocub for Acquia commentedComment #45
maxocub CreditAttribution: maxocub as a volunteer and for Acquia commented