Loading CHANGELOG.txt +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ Next release ============ Features and enhancements - #2397791 - Provide detailed field validation errors. - #2309563 - Add support for running migrations via wildcard name. - #2095841 - Abstract mail system disablement for more flexibility. - #2419373 - Provide ability to cache map lookups. Loading plugins/destinations/comment.inc +1 −1 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ class MigrateDestinationComment extends MigrateDestinationEntity { } // Validate field data prior to saving. field_attach_validate('comment', $comment); MigrateDestinationEntity::fieldAttachValidate('comment', $comment); migrate_instrument_start('comment_save'); comment_save($comment); Loading plugins/destinations/entity.inc +30 −0 Original line number Diff line number Diff line Loading @@ -176,4 +176,34 @@ abstract class MigrateDestinationEntity extends MigrateDestination { } } } /** * Perform field validation against the field data in an entity. Wraps * field_attach_validate to handle exceptions cleanly and provide maximum * information for identifying the cause of validation errors. * * @param $entity_type * The type of $entity; e.g. 'node' or 'user'. * @param $entity * The entity with fields to validate. */ static public function fieldAttachValidate($entity_type, $entity) { try { field_attach_validate($entity_type, $entity); } catch (FieldValidationException $e) { $migration = Migration::currentMigration(); foreach ($e->errors as $field_name => $field_errors) { foreach ($field_errors as $langcode => $errors) { foreach ($errors as $delta => $error_list) { foreach ($error_list as $index => $error) { $message = $error['message']; $migration->saveMessage(t('Field validation error for !field_name: !message', array('!field_name' => $field_name, '!message' => $message))); } } } } } } } plugins/destinations/fields.inc +1 −1 Original line number Diff line number Diff line Loading @@ -530,7 +530,7 @@ class MigrateTaxonomyTermReferenceFieldHandler extends MigrateFieldHandler { // This term is being created with no fields, but we should still call // field_attach_validate() before saving, as that invokes // hook_field_attach_validate(). field_attach_validate('taxonomy_term', $new_term); MigrateDestinationEntity::fieldAttachValidate('taxonomy_term', $new_term); taxonomy_term_save($new_term); $tids[] = $new_term->tid; Loading plugins/destinations/node.inc +1 −1 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ class MigrateDestinationNode extends MigrateDestinationEntity { } // Validate field data prior to saving. field_attach_validate('node', $node); MigrateDestinationEntity::fieldAttachValidate('node', $node); migrate_instrument_start('node_save'); node_save($node); Loading Loading
CHANGELOG.txt +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ Next release ============ Features and enhancements - #2397791 - Provide detailed field validation errors. - #2309563 - Add support for running migrations via wildcard name. - #2095841 - Abstract mail system disablement for more flexibility. - #2419373 - Provide ability to cache map lookups. Loading
plugins/destinations/comment.inc +1 −1 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ class MigrateDestinationComment extends MigrateDestinationEntity { } // Validate field data prior to saving. field_attach_validate('comment', $comment); MigrateDestinationEntity::fieldAttachValidate('comment', $comment); migrate_instrument_start('comment_save'); comment_save($comment); Loading
plugins/destinations/entity.inc +30 −0 Original line number Diff line number Diff line Loading @@ -176,4 +176,34 @@ abstract class MigrateDestinationEntity extends MigrateDestination { } } } /** * Perform field validation against the field data in an entity. Wraps * field_attach_validate to handle exceptions cleanly and provide maximum * information for identifying the cause of validation errors. * * @param $entity_type * The type of $entity; e.g. 'node' or 'user'. * @param $entity * The entity with fields to validate. */ static public function fieldAttachValidate($entity_type, $entity) { try { field_attach_validate($entity_type, $entity); } catch (FieldValidationException $e) { $migration = Migration::currentMigration(); foreach ($e->errors as $field_name => $field_errors) { foreach ($field_errors as $langcode => $errors) { foreach ($errors as $delta => $error_list) { foreach ($error_list as $index => $error) { $message = $error['message']; $migration->saveMessage(t('Field validation error for !field_name: !message', array('!field_name' => $field_name, '!message' => $message))); } } } } } } }
plugins/destinations/fields.inc +1 −1 Original line number Diff line number Diff line Loading @@ -530,7 +530,7 @@ class MigrateTaxonomyTermReferenceFieldHandler extends MigrateFieldHandler { // This term is being created with no fields, but we should still call // field_attach_validate() before saving, as that invokes // hook_field_attach_validate(). field_attach_validate('taxonomy_term', $new_term); MigrateDestinationEntity::fieldAttachValidate('taxonomy_term', $new_term); taxonomy_term_save($new_term); $tids[] = $new_term->tid; Loading
plugins/destinations/node.inc +1 −1 Original line number Diff line number Diff line Loading @@ -263,7 +263,7 @@ class MigrateDestinationNode extends MigrateDestinationEntity { } // Validate field data prior to saving. field_attach_validate('node', $node); MigrateDestinationEntity::fieldAttachValidate('node', $node); migrate_instrument_start('node_save'); node_save($node); Loading