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.
In the Get migrate processor plug-in Get->multiple() returns null when source is array, and as array, there will be multiple values, so it should return TRUE.
Comment | File | Size | Author |
---|---|---|---|
#7 | interdiff-get_migration_plugin-2884019-2-7.txt | 581 bytes | edurenye |
#7 | get_migration_plugin-2884019-7.patch | 1.07 KB | edurenye |
#2 | get_migration_plugin-2884019-2.patch | 519 bytes | edurenye |
Comments
Comment #2
edurenye CreditAttribution: edurenye at ENDPHASYS Technologies commentedDone.
Comment #4
edurenye CreditAttribution: edurenye at ENDPHASYS Technologies commentedI found this issue trying to find why the processors with handle_multiple false, with multiple sources where receiving an array, when processRow is suposed to handle that, and it was because of the Get processor setting multiple from FALSE to NULL in MigrateExecutable->processRow()
Comment #5
mikeryanCould you elaborate some more on the problem you're seeing? Perhaps an example .yml that isn't working as you expect?
Comment #6
edurenye CreditAttribution: edurenye at ENDPHASYS Technologies commentedI was importing a product entity and I had this processor to fill a field with products of the same kind but different color:
The current migration is migrate_cases_csv.
As migration_lookup has handle_multiple to FALSE (default) and field_also_available is a multivalued field, I expect the processor to iterate the sources in MigrateExecutable->processRow() and fill a new entry for each source, but as in reality this executes first the Get plugin and then the migration_lookup plugin, In this fragment of code inside processRow():
Get in the first iteration is setting multiple to NULL when it is returning an array, so should set it to TRUE.
But setting it to null acts like with FALSE, so it gives the value to migrate_lookup without iterate over it, and migrate_lookup behaves unexpectedly as it just returns the first that it finds.
Comment #7
edurenye CreditAttribution: edurenye at ENDPHASYS Technologies commentedThe failing tests are because there are other process plugins that should have handle_multiples TRUE, as the can do it, but they where relying in this wrong behavior of Get.
One example that I'm fixing here is FileCopy, that handles multiples as expects an array of source and destination, but did not have handle_multiples.
Comment #9
mikeryanSo, here:
You are expecting that the two fields will be merged into a single array of source values. That's not how it works - rather, migration_lookup takes them as two parts of a multi-value key to look up (i.e., in the migration map table it'll want to look for sourceid1=color_available_1 and sourceid2=color_available_2). You need to separately merge those values into a single value array to pass to migration_lookup. I believe this will work (assuming those are scalar values):
Comment #10
edurenye CreditAttribution: edurenye at ENDPHASYS Technologies commentedThis is not working.
As multiple by default is FALSE even with array, because of that, Get gets called just once, but as Get does not care of value but uses the config property source, it gets the array and returns it, so there is no actual difference between
this:
and this:
I still think this is a bug in Drupal as the behavior of handle_multiple does not match the documentation https://api.drupal.org/api/drupal/core%21modules%21migrate%21src%21Annotation%21MigrateProcessPlugin.php/property/MigrateProcessPlugin%3A%3Ahandle_multiples/8.3.x
Comment #12
heddnIf we can reproduce this, please re-open.
Comment #13
edurenye CreditAttribution: edurenye at ENDPHASYS Technologies commentedI still think that this is a bug as the MigrateProcessPlugin behaves different from the documentation, so we have to change documentation or the plug-in.
And as I said the response from 9 is not working.
Comment #22
quietone CreditAttribution: quietone at PreviousNext commentedI read the issue and I also don't see the bug here or a problem with the documentation. If field_also_available is a multi-value field then I would expect to the sub_process plugin to be used to get the values for the other colors.
Steps to reproduce 5 years ago and that has not been provided nor has suggestions for changes to documentation. I'm marking the issue "Closed (cannot reproduce)". If anyone can provide complete steps to reproduce the issue (starting from "Install Drupal core"), document those steps in the issue summary and set the issue status back to "Active".
Thanks.