Migrate UI runs the following code to show all source fields:
if (isset($source_key[$machine_name])) {
// Identify primary key
$machine_name .= ' ' . t('(PK)');
}
else {
// Add class for mapped/unmapped. Used in summary.
$classes = !isset($source_fields[$machine_name]) ? 'migrate-error' : '';
}
$rows[] = array(
array('data' => check_plain($machine_name), 'class' => $classes),
array('data' => filter_xss_admin($description), 'class' => $classes),
);
Compare this to the code to show all destination fields:
$classes = array();
if (isset($dest_key[$machine_name])) {
// Identify primary key
$machine_name .= ' ' . t('(PK)');
}
else {
// Add class for mapped/unmapped. Used in summary.
$classes[] = !isset($destination_fields[$machine_name]) ? 'migrate-error' : '';
}
$rows[] = array(
array('data' => check_plain($machine_name), 'class' => $classes),
array('data' => filter_xss_admin($description), 'class' => $classes),
);
The former causes the PK field to show as unmapped when the previous field was unmapped because $classes isn't reset. The latter at least resets the $classes variable (and correctly uses it as an array!), but still does not account for an unmapped PK.
Attached is a patch that makes both pieces of code flag an unmapped PK correctly.
Comments
Comment #2
kristiaanvandeneyndeComment #3
mikeryanI tried this patch with a munged beer example (changed the BeerNode query to put the 'bid' after 'excerpt' and unmapped 'excerpt'), but it results in the destination nid and source bid always being flagged as unmapped. It's true that they are not part of any explicit field mappings, but this is normal - most migrations do not migrate IDs but rather let the destination side assign a new ID. Source and destination IDs are implicitly "mapped" by their usage for the map object, and shouldn't be flagged as if they need to have explicit field mappings.