dgrigg / craft-migration-assistant

Migration Manager for Craft CMS
Other
27 stars 10 forks source link

Fields from type "Time" are not migrated correctly (will be set to null because of wrong format) #45

Open benediktblank opened 2 years ago

benediktblank commented 2 years ago

Importing entries that have fields from type "Time" does not work correctly. These entries will lose the value set in the fields from type "Time" because the format is wrong.

Steps to reproduce:

  1. Create a section with a "Time" field
  2. Create an entry and set a time in the "Time" field
  3. Create an entry migration with the migration assistant
  4. Import the migration with the migration assistant

Expected result:

  1. The value in the "Time" field is still the same

Actual result:

  1. The value in the "Time" field is empty/null

Attached you find three migrations to get started quicker. Migration for field, section and the entry. migrations.zip

Note for a possible fix: The format in the migration for that field is currently this: "timetestfield":{"date":"2022-04-27 02:30:00.000000","timezone_type":3,"timezone":"America/Los_Angeles"}

That's what causes the issue.

The value gets "nulled" here: vendor/craftcms/cms/src/validators/ElementUriValidator.php

Which is called during field validation during the import.

It can be fixed/prevented with changing that value to a simple time string, like this: "timetestfield":"02:30:00"

So the issue lies in the migration creation.

benediktblank commented 2 years ago

@dgrigg Were you able to have a look into that already?

dgrigg commented 2 years ago

@benediktblank I'm looking into it while working on our Craft 4 updates.