Why are SourceMigrations skipped with "If any source keys are empty, skip this set"?
In migration.inc there is code that will skip a source migration mapping for multiple keys array, if a single value is empty. I guess this is not intended.
So the source igration can not be retrieved, when I got a set, like:
- street: My Street
- street2: ""
- zip: 30159
- city: Hannover
I guess the intended behaviour is, to skip an element, when ALL values are empty - and not, like it is currently, to skip it if any is empty.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | empty_key_value-1831940-4.patch | 676 bytes | mikeryan |
| #1 | multi_source_key_migration-11831940-1.patch | 786 bytes | derhasi |
Comments
Comment #1
derhasi commentedI wrote a small patch to fix that.
Comment #2
mikeryanNo, it is intended - the key here is serving as a primary key on the source, and all elements of the key must not be null. An address, as in your example, doesn't seem like a reliable way to uniquely identify a row - is there no combination of non-NULL values in your source data that can serve as a proper key?
Comment #3
derhasi commented@mikeryan,
""is NOT NULL. I'ts just an empty textIf you want to skip the step where any key is NULL, then we should use
!isset()instead of!empty($value) || $value === 0 || $value === '0'. This would make sense to me.To get back to your address question. No there unfortunately is no other way. In some cases even an empty value (not NULL) should be a valid (part of a) key.
Comment #4
mikeryanThis seems a bit simpler, does it work for you?
Thanks.
Comment #5
derhasi commentedCannot test it right now, but seems fine to me.
Comment #6
pwolanin commentedI think !isset() is preferred, from the comments on php.net
Comment #7
mikeryanCommitted (with !isset) to the wizard_api branch, thanks.
Comment #9
imiksuHi! I've been struggling with one of my migrations after updating from 2.5 to 2.8 and turns out that this patch has created an regression.
I have an migration for hierarchial taxonomy terms and I use parent as one of my field mappings together with
->sourceMigration($this->getMachineName()).Unluckily my source has an an foreign ID "0" which is the ID of a root term. So, after my upgrade all my second level terms are now considered as root terms. Is there way to improve this issue's patch by covering that case too without breaking the original fix?