Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
All D6 Integer, Float, Decimal or Text fields are converted to Number(Integer) or Text fields in D8. These new fields don't support check boxes, radio buttons, or select lists.
Proposed resolution
When migrating Integer, Float, Decimal or Text fields we need to check the widget and use that as part of the map when figuring out which widget to use.
D8field = D6field:D6widget list_text = text:optionwidgets_select list_text = text:optionwidgets_buttons boolean = text:optionwidgets_onoff text = text:text_textfield long_text = text:text_textarea integer = number_integer:number list_integer = number_integer:optionwidgets_select list_integer = number_integer:optionwidgets_buttons boolean = number_integer:optionwidgets_onoff decimal = number_decimal:number list_float = number_decimal:optionwidgets_select list_float = number_decimal:optionwidgets_buttons boolean = number_decimal:optionwidgets_onoff float = number_float:number list_float = number_float:optionwidgets_select list_float = number_float:optionwidgets_buttons boolean = number_float:optionwidgets_onoff
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#59 | d6_d8_cck_single-2262275-59.patch | 24.82 KB | hussainweb |
#59 | interdiff-53-59-2.txt | 574 bytes | hussainweb |
#59 | interdiff-53-59.txt | 2.68 KB | hussainweb |
Comments
Comment #1
ultimikeComment #2
hosef CreditAttribution: hosef commentedComment #3
hosef CreditAttribution: hosef commentedComment #4
hosef CreditAttribution: hosef commentedComment #5
hosef CreditAttribution: hosef commentedHere are some tests.
Comment #6
hosef CreditAttribution: hosef commentedComment #7
hosef CreditAttribution: hosef commentedComment #8
hosef CreditAttribution: hosef commentedComment #9
ultimikeComment #10
hosef CreditAttribution: hosef commentedHere is a fix for the issue that involves greatly expanding the field type map. Another option would be to create a process plugin to handle the field types.
I, also modified several of the tests so that they provide better feedback.
Comment #11
hosef CreditAttribution: hosef commentedComment #13
hosef CreditAttribution: hosef commentedOk, let's try this again.
Comment #15
hosef CreditAttribution: hosef commentedI forgot to add the unsupported_field_handler class to my patch. I, also, had to change some of the test data because a few of the new fields that I added to the test were miss-formatted.
Comment #16
ultimike@hosef,
This is really great work!
I applied the patch to my local and ran a manual test, and I think we still have some issues we need to work out.
On my local D6 test site, I created a decimal select list field and created a couple of nodes using the field, the migration appeared to run fine, and the field values appear to be migrated correctly, but there are two issues I noticed:
On another (minor) note:
Stuff like this should probably be written as
$this->assertEqual($field->type, "text", t('Field type is @fieldtype. It should be text.', array('@fieldtype' => $field->type)));
-mike
Comment #17
hosef CreditAttribution: hosef commentedOk, here is an updated patch with the requested changes. It turns out that it wasn't parsing the allowed values from Drupal 6 but was just passing it in as a string like 'key1|value1\r\nkey2|value2', and that was causing the white screens.
There is still one place where it white screens though. When I create a field that gets migrated over as a Boolean and then go to the field instance settings page, I get the following in my Apache log followed by a stack trace:
Fatal error: Call to a member function form() on a non-object in /var/www/drupal8/core/lib/Drupal/Core/Field/FieldItemList.php on line 319
There is also an undefined offset error when I run the tests that I haven't been able to figure out.
If anyone knows where I should look to fix those, that would be great.
Comment #18
hosef CreditAttribution: hosef commentedOops, didn't mean to change the status.
Comment #20
chx CreditAttribution: chx commentedFirst Rule Of Migration Debug: Never try to debug MigrateDrupal6Test! That way only lies burnout.
That's why we have the small tests, to have something debuggable. You got lucky cos both tests fail the same.
Well, CMI uses dot as an array delimiter so what this try to is
$config['settings']['allowed_values'][1][2] = '1.2';
Does that help? I hope it does.
Also Drupal codign standards put the else on a separate line
thanks.
Comment #21
hosef CreditAttribution: hosef commentedOk, I've changed it so that it replaces the
.
with an_
in the allowed values key.I've, also, moved the else's onto their own lines.
Comment #22
ultimikeIt might be worth it to move the regex stuff into its own process plugin (as benjy suggested), seeing how it is used in patch 21 above but also in #2281627: Freeform text profile field does not migrate properly from D6 to D7.
Thanks,
-mike
Comment #23
hosef CreditAttribution: hosef commentedI'm a little confused. The regex stuff is already in a process function. Is it possible to call another process function from within a process function? If so, is that a good idea? That would mean that we would be using multiple process functions, but you would not be able to tell that by simply looking at the .yml file for that migration.
I do think the new regex in the other issue looks much nicer though.
Comment #24
ultimikehosef and I chatted on IRC about this and we decided to proceed as follows:
Thanks,
-mike
Comment #25
hosef CreditAttribution: hosef commentedHere is the new patch with the cleaner regex.
Comment #26
ultimikehosef,
As promised, I did some manual testing and found some good stuff and some bad stuff. First, the good:
The widget mapping appears to be working great. I created a select list (integer), radio buttons (decimal), and checkboxes (text), and the widget settings were migrated properly into D8.
On a test node, the selected values for the checkboxes (text) were migrated fine as well, they were displayed/selected properly on both the node edit and view pages.
Unfortunately, the selected values for the select list (integer) and radio buttons (decimal) fields on test nodes didn't fare so well:
Both of these appear to be ripe for an automated test (and a fix).
Let me know if you need further explanation on my results.
Thanks,
-mike
Comment #27
ultimikeComment #28
ultimikeThe patch in 25 no longer applies cleanly (something with $field->status() vs. $field->status), so I re-rolled it. Diving back into this issue now.
-mike
Comment #29
ultimikeAttaching a new patch that I believe modifies the MigrateFieldTest and MigrateCckFieldValuesTest to capture the two issue I reported in comment 26 above.
I'm pretty confident that the addition to MigrateFieldTest that I made reflects the "underscore" issue. I'm slightly less confident that I modified the MigrateCckFieldValuesTest properly to capture the missing select list (integer) value.
My next step is to debug the migration to try to get these new tests to pass.
Thanks,
-mike
Comment #30
ultimikeFor the decimal/float allowed values issue (item 1 from comment 26), this is related to #2293773: Field allowed values use dots in key names - not allowed in config. How that patch ultimately lands will dictate the fix for this bug.
-mike
Comment #31
ultimikeI chatted with chx about this today, he also thinks that #2293773: Field allowed values use dots in key names - not allowed in config will go a long way in solving the "use a decimal as a key" issue.
I'll continue working on the "missing select list (integer)" part of this patch.
Thanks,
-mike
Comment #32
hussainwebJust rerolling for now and testing. It is a reroll of #29 and resolving conflicts against #2287727: Rename FieldConfig to FieldStorageConfig.
Comment #33
hussainwebI have been wondering why we are introducing a
UnsupportedFieldHandler
plugin here. If I understand it correctly, this plugin will skip the row if the map has missed transforming the value. Isn't that the behaviour if we just removebypass
fromstatic_map
? I am attaching a patch for this to see what the testbot thinks.Comment #35
chx CreditAttribution: chx commentedThanks, that's a great idea, I was overcomplicating things.
Comment #36
hussainwebI missed out a couple of references to
field_config
from the old patch. I think I got them all now.UPDATE: This builds on the patch in #33 with
UnsupportedFieldHandler
removed.Comment #39
hussainwebOne of the test failures is due to a typo in field name in the test. I have fixed that with this patch. The other four failures are due to the float in keys being changed to underscore, as @ultimike mentioned in #26. From the current discussion in #2293773: Field allowed values use dots in key names - not allowed in config, we probably won't have to change the
'.'
to'_'
once that issue is fixed. I have added a TODO in the patch for that (probably not required, but anyway).I also reviewed the patch again, particularly changes to
process/FieldSettings.php
and simplified code a bit:I replaced this entire if-elseif-else block with a switch.
I removed this (and one other) if/else blocks in favour of ternary operators.
I changed the
implode('_', explode('.', ...))
bit to a simplestr_replace
.In the last else in that block of code, I removed the entire foreach loop and simply assigned the value to
$allowed_values
.I posted this bit because the interdiff might not show these in an obvious way (because of additional indentation in switch block).
There should be 8 total failures with this patch now, which are related to the decimal point in allowed values key and is dealt with in #2293773: Field allowed values use dots in key names - not allowed in config. There is no point fixing that here (or even changing it to underscore, as that might be a regression?) We'll just have to wait until that fix gets in.
Comment #41
ultimike@hussainweb - this is great stuff, thanks so much.
Did you by any chance run a manual test to confirm that your latest patch handles the other bug I found (see comment 26, point 2) - the "missing select list (integer)" stuff? (thanks for catching the typo - doh!)
Thanks,
-mike
Comment #42
hussainwebThanks @ultimike.
I went through the comment in #26.2 and ran a manual test. I created a Integer field with Select list widget on a D6 site and devel generated 50 nodes. I ran a migration using the manifest in #2222375-6: Manual Testing: Nodes and found that the nodes in destination had the correct value set in both node edit form and node view page.
Am I missing something here? Can you please post exact steps to reproduce the problem. If it helps, I ran the test with the patch from #39 and #2306049-1: D6->D8 node migration - Handle nodes with format = 0 ? (which shouldn't matter here, but I needed it to migrate devel generated nodes).
On another note, #2293773: Field allowed values use dots in key names - not allowed in config is close to being RTBC'd, which is good news for this issue too. I think once that gets in, we won't need to make any changes here, just retest it as it is to fix those test failures (unless we have to reroll it).
Comment #43
ultimike@hussainweb,
I just manually retested for the "integer select" and it appears to be working. Not sure if I goofed on my initial manual test or what happened, but based on your and my testing, it looks like we're good.
As you said, let's keep our fingers crossed that #2293773: Field allowed values use dots in key names - not allowed in config takes care of decimal selects.
Since you asked, here's the steps to reproduce my manual test for the "integer select" bug:
Thanks,
-mike
Comment #44
hussainweb#2293773: Field allowed values use dots in key names - not allowed in config is in, which means it's time to retest this.
Comment #47
hussainwebIdentical failures. I will continue debugging this.
@ultimike: Just to confirm, the issue with select list is not reproducible, right?
Comment #48
ultimike@hussainweb, yes, at this time, I am unable to reproduce the select list issue. Hope that's a good sign!
Thanks,
-mike
Comment #49
ultimikeAttached patch fixes the MigrateCckFieldValuesTest - there was some incomplete dump data.
I forgot to create a new branch to make an interdiff, so sorry.
The two main changes are:
The MigrateFieldTest still has some issues that will need to be resolved before this patch is ready to be reviewed.
Thanks,
-mike
Comment #50
ultimikeOk - I have this one to where all tests are passing.
Updated patch and interdiff attached.
Thanks,
-mike
Comment #51
chx CreditAttribution: chx commentedAwesome! I think I only have one question left. Given D6
why are we adding
us_0
to text when the formatter only applies to number field types? Is this something somehow CCK allowed for real??Comment #52
hussainwebI agree with @chx in #51. I am trying to remove it and see what happens. I don't think there will be any failures.
I did a grep for us_0 in cck module in a D6 site and could not find any other usage apart from the one in number.module as listed above. I think this was a typo introduced in #15. This line was not present before the patch in that comment.
Comment #53
hussainwebThanks @chx, for pointing out the field instances that need updating. As discussed on IRC, I have removed unformatted from text field formatter mapping as well.
Comment #55
benjy CreditAttribution: benjy commentedCan we add a use statement?
Comment #56
chx CreditAttribution: chx commentedThanks! This is almost ready. There's one more thing I would like to discuss (sorry for not catching it earlier):
$d6_allowed_values = preg_split("/[\r\n,]+/", $global_settings['allowed_values']);
. Where does that preg_split expression come from? I looked for validating with allowed_values and if I am not mistaken then http://drupalcontrib.org/api/drupal/contributions%21cck%21modules%21text... this is it and it calls http://drupalcontrib.org/api/drupal/contributions!cck!content.module/fun... which doeswhich we might actually want to keep. But first, where is that preg from? #17 says
I would recommend adopting the D6 code instead of inventing our own especially because our own picked up a comma from somewhere, I'm not quite sure where. Although I seem to remember having this discussion over at profile too and that was wrong, too. Also, I am reasonably sure that
key|value_line1\rvalue_line2
will be completely valid in the D6 code because \r wasn't a delimiter (it was removed from the end of the line after explode by trim but it wasn't a delimiter).Comment #57
hussainwebThere are multiple things I want to bring up here:
I am trying to figure out the comma, but can't find it. Like @chx says, we should just remove it and use the strategy of content_allowed_values which seems to be called from all modules.
More to the point, the comma might actually break tests if the allowed values key or label had a comma.
In D6 CCK, allowed values were a valid setting for text even if the widget did not allow selection. Typing in a value not present in the allowed values list would throw a validation error when creating the node. Does this make sense for Drupal 8 now? If so, we should migrate it. If not, we should document that any field using allowed values but not using one of those widgets would lose that ability.
Is this necessary? The code does nothing in this case. Consider the function:
The if condition would always fail for the $settings array in our case. But the tests still work. I think the reason is we don't have to worry about calling this methods. Field storage takes care of that.
Comment #58
hussainwebElaborating more on #57.2, I don't think we can use allowed values for other field types. We have to document that users would lose this on migration. If they wish to avoid that, they have to change the widget on D6 site before upgrading.
Comment #59
hussainwebAttaching patch with fixes for issues raised in comments #55, #56 and #57.
Particularly, I am removing the line
$settings = ListItemBase::settingsToConfigData($settings);
as I believe it doesn't do anything in this case. We have tests for checking this and if this line is necessary, the test would fail. So, let's see.I should warn about the two interdiffs. I forgot to remove the use declaration for ListItemBase much later and I didn't have enough energy to start again. However, the patch is final with both interdiffs applicable.
Comment #60
ultimike@hussainweb, @chx, @benjy,
Thanks for (hopefully) pushing this across the finish line. I just did some manual testing with the patch in 59 and didn't see any issues.
-mike
Comment #61
chx CreditAttribution: chx commentedI think we are good to go. As for #57.2 that's a bad joke. We can add it to the known issues pile but seriously, making you fail on text input without giving you even a hint of what you can type? That's the worst UX possible... and I doubt anyone ever used it. Anyways, I do not think we have the ability any more nor we should have it.
Comment #62
hussainwebI agree about the UX part. It doesn't make sense and it is good that we don't have it anymore. But since this could be counted as data loss, I think we should at least document this somewhere (I am not sure where).
Comment #63
chx CreditAttribution: chx commentedhttps://www.drupal.org/node/2167633
Comment #65
alexpottCommitted 267202b and pushed to 8.x. Thanks!