- Issue created by @hongpong
- 🇺🇸United States hongpong Philadelphia
add something like this - catch and log exception https://www.drupal.org/node/2932520 →
exceptions docs - https://www.drupal.org/docs/develop/coding-standards/php-exceptions →
transaction rollback - $transaction->rollBack(); - https://drupal.stackexchange.com/questions/311933/how-to-properly-log-cu...
core migrate exceptions https://api.drupal.org/api/drupal/core%21modules%21migrate%21src%21Migra...
migrate executable class handle exceptions -https://api.drupal.org/api/drupal/core%21modules%21migrate%21src%21Migra...
examples of caught migrate exceptions #2969551: Migrate messages from caught exceptions need file and line details →
more about managing migration exceptions https://www.phase2technology.com/blog/migration-making-it-all-work
- Status changed to Needs work
over 1 year ago 2:24am 30 September 2023 - 🇺🇸United States hongpong Philadelphia
This catches the exceptions - both EntityStorageException and generic exception. so it is not a fatal error. However then there is a spew of missing XML file, ( Warning: XMLReader::open(): Unable to open source data in Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Xml->openSourceUrl() (line 177 of modules/contrib/migrate_plus/src/Plugin/migrate_plus/data_parser/Xml.php). )
so i think the following lines after the exception need to be changed - they should not run i think .
// Go to the dashboard for this migration group. $form_state->setRedirect('entity.migration.list', ['migration_group' => $cached_values['group_id']]); parent::finish($form, $form_state); }
- First commit to issue fork.
- 🇳🇮Nicaragua baltowen
This problem is caused because we are using
#default_value
in a#machine_name
render element. Per the documentation of the exist callback...exists: A callable to invoke for checking whether a submitted machine name value already exists. The arguments passed to the callback will be:
- The submitted value.
- The element array.
- The form state object.
In most cases, an existing API or menu argument loader function can be re-used. The callback is only invoked if the submitted value differs from the element's initial #default_value. The initial #default_value is stored in form state so AJAX forms can be reliably validated.
Because we are using the
#default_value
property, the callback to check whether an entity exists is never called. Later on when the migration group is being created, it fails with a duplicate error.We can either remove the
#default_value
property altogether. Or as suggested in the MR, change it to a HTML placeholder attribute. For the latter, we need to consider some accessibility concerns. See image below: - 🇺🇸United States hongpong Philadelphia
Thanks baltowen that definitely helps! It would be better to prevent this from even happening but I think it would still improve matters to have it in there. If there is a quick way to add migration group naming form field validator function, then the submission would be blocked from proceeding
It is possible in the future that the wizard would not be used, (eg drush) so its good to have additional checks added.
- 🇺🇸United States hongpong Philadelphia
Ok that worked great, thank you baltowen, it is committed on 8.x-3.x. I might go back to add more coverage for exceptions but for now let's just keep this simple.
Automatically closed - issue fixed for 2 weeks with no activity.