Problem/Motivation
I found this in attempt to manually test node migration as in #2225165: Missing titles in simple D6->D8 node migration. I setup a new D6 site with admin_menu, cck (text and number), devel_generate. I set up a new D8 instance with latest HEAD and ran:
drush migrate-manifest --legacy-db-url=mysql://..:..@localhost/d6 ../D6Manifest-Node_0.yml
The manifest is from #2222375-6: Manual Testing: Nodes and I slightly modified it as per migrate_upgrade's manifest. I changed d6_cck_field_values:*
and d6_cck_field_revision:*
to d6_cck_field_values
and d6_cck_field_revision
respectively.
The first run failed and I assumed there was something wrong with field migrations as I had not actually added any cck fields to nodes yet. I did that, regenerated 50 nodes and ran migration again (and also with the UI module just in case). It eventually showed that node migration was successful but did not actually migrate any rows. I found that the map table had set all source rows to STATUS_IGNORED
(2).
On debugging, I found the reason to be that the devel_generate had generated all nodes with format = 0 and this process would skip the row:
'body/format':
plugin: migration
migration: d6_filter_format
source: format
On searching, I found another issue: #2207823: Handle bogus/missing D6 format values which went about it quite differently (the patch in the issue is overwritten with a different approach in the current HEAD). Current relevant block:
signature_format:
-
# Drupal 6 stores 0 as the signature format when signatures are disabled.
# Drupal 8 stores a NULL.
plugin: static_map
bypass: true
source: signature_format
map:
0: NULL
-
# Do not try to migrate the NULL format.
plugin: skip_process_on_empty
-
plugin: migration
migration: d6_filter_format
no_stub: 1
The reasoning seems okay for signature field (as it is assumed disabled if the format is 0, but in case of nodes, there could be valid reasons to migrate the nodes even if this happens.
Proposed resolution
We could use the same approach as the current implementation in migration.migrate.d6_user.yml as shown in the block above.
Remaining tasks
Write the patch.
User interface changes
None
API changes
None
Comment | File | Size | Author |
---|---|---|---|
#17 | 2306049-17.patch | 2.62 KB | ultimike |
Comments
Comment #1
hussainwebPutting in a basic patch just for testing. It worked in manual testing. All nodes migrated using the drush command shown in the issue summary.
Comment #2
hussainwebThe patch works and manually migrating from D6 -> D8 works fine. However, I think this wouldn't handle non-zero missing filter id's. Is there a way for 'migration' process to skip process instead of skipping row?
Comment #3
benjy CreditAttribution: benjy commentedI know you just copied this wholesale from the d6_user migration but I'm not even sure where this is used? It doesn't seem to be documented either: https://www.drupal.org/node/2149801
Is there a way for 'migration' process to skip process instead of skipping row?
Isn't that exactly what you're doing with
skip_process_on_empty
. ?Comment #4
hussainweb@benjy: You are right about no_stub. It was copied from d6_user migration. I just did that to get this started. There seems to be a reference to this in
Drupal\migrate\Plugin\migrate\process\Migration
:Of course, it seems it was changed later but the reference from 'no stub' doesn't seem to have been updated. The patch in #2207823-4: Handle bogus/missing D6 format values shows the original key in yml file as 'no stub', but currently it is no_stub. Like I said, I just copied it but this could be another issue?
Yes, but I have to set up this elaborate structure to do that and it all happens before migration plugin is even called. Even with this, all scenarios are not handled like I explained. For non-zero format id's, it will still fall to migration and skip the entire row rather than just the process.
I think what is required here is having an option on plugin like this:
if fail_behaviour is skip_process, the appropriate exception is thrown instead. New issue for this too?
Comment #5
benjy CreditAttribution: benjy commentedA default_value option on the migration plugin would work? That would be more inline with what we've done elsewhere, eg static_map
Comment #6
hussainweb@benjy: That is more or less what I mean but I think
default_value
sounds a bit misleading. If the migrate process plugin fails, we are not going to assign a default value, but skip the process entirely (or the whole row, by default). I understand that skipping the process amounts to just setting a default value on that field, but there may be cases when the default value should be left to the runtime (i.e., when the destination is created, and not defined by the mapping.)What do you think?
Comment #7
chx CreditAttribution: chx commentedReplace 0 with the D6 default format in the source prepareRow?
Comment #8
benjy CreditAttribution: benjy commentedLets just go with skipping the whole row if the migration look up fails.
And yes, I think we need a new issues for the "no stub" issue.
Comment #9
ultimikeComment #10
benjy CreditAttribution: benjy commentedIf we fix the stub issue then the Migration process plugin will skip the row for us when the filter lookup misses and no_stub is true. Patch attached but postponing on #2337749: no_stub is never used
Comment #11
benjy CreditAttribution: benjy commentedComment #12
benjy CreditAttribution: benjy commentedComment #13
chx CreditAttribution: chx commentedI was wondering whether normal d6 would create 0 format but no, that's just not happening, it's still a form driven Drupal and the filter options are coming from a serial and serials are fundamentally unzero (unlike users.uid which causes so much pain).
Comment #14
webchickCorrect me if I'm wrong, but it seems like we should have tests for this? Esp. since we'd want it to handle the same condition in D7 as well, ideally.
Comment #15
ultimikePatch re-rolled with test.
-mke
Comment #16
benjy CreditAttribution: benjy commentedCan we change this to assertIdentical. Over in #2345833: Convert assetEqual to assertIdentical in migrate_drupal i'm planning on getting rid of as many assertEquals as possible, especially when the values we're comparing are 0, '', 1, true, false, null etc
Comment #17
ultimikeBenjy - no problem - patch updated with assertIdentical.
No interdiff, but the only change is that one line.
-mike
Comment #20
benjy CreditAttribution: benjy commentedTest looks fine to me, should be green so RTBC.
Comment #21
alexpottCommitted 6fa8507 and pushed to 8.0.x. Thanks!
Comment #23
penyaskitoIs #2207823: Handle bogus/missing D6 format values a duplicate of this one?