Problem/Motivation

As shown in #2699895: Add settings to define #date_increment for datetime and datetime_range 'default' widgets, the Drupal 7 date module allowed the site builder to configure which granularity to collect:

For example, on my personal site, I have a project NodeType which has a "time range" date field that only cares about year + month granularity. Example: https://wimleers.com/work/project/cdn-far-future-expiration-drupal-7 and https://wimleers.com/work/project/ledgrid.

When migrating this to Drupal 8, \Drupal\datetime\Plugin\migrate\field\DateField::defineValueProcessPipeline() chokes on this. This causes big warnings even before migrating/upgrading, i.e. upon going from /upgrade to /upgrade/review.

Furthermore, it seems that the migration expects those granularities to be keys, but on my site they're values? 🤷‍♂️

Proposed resolution

Make \Drupal\datetime\Plugin\migrate\field\DateField::defineValueProcessPipeline() more robust.

Remaining tasks

Commit.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

TBD

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new674.14 KB
new751.7 KB
new1.22 KB
wim leers’s picture

StatusFileSize
new1.1 KB
new2.28 KB

Just spotted lots of errors like this in my migration:

Notice: Undefined index: hour in Drupal\field\Plugin\migrate\process\d7\FieldSettings->transform() (line 32 of /Users/wim.leers/Work/d8/core/modules/field/src/Plugin/migrate/process/d7/FieldSettings.php) 

Same root cause, similar fix.

wim leers’s picture

Title: Drupal 7 date fields configured to not collect the hour/minute/second granularities fail to migrate » Drupal 7 date fields configured to not collect the hour/minute/second granularities can have a different "settings" structure than the migration assumes

The last submitted patch, 2: 3095146-2.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 3: 3095146-3.patch, failed testing. View results

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new1.84 KB
new2.31 KB
wim leers’s picture

StatusFileSize
new1012 bytes
new3.25 KB

#7 should come back green.

But let's also add explicit test coverage. Based on wimleers.com's D7 database, see screenshot in the issue summary.

The last submitted patch, 8: 3095146-8-test_only_FAIL.patch, failed testing. View results

wim leers’s picture

Component: datetime.module » migration system

Been told that I should put this in migration system :)

heddn’s picture

Good IS. Good test coverage. Good fixes. RTBC.

dww’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

I think @heddn meant to change the status in #11.

I also just closely reviewed and agree this is RTBC.

Thanks,
-Derek

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: 3095146-8.patch, failed testing. View results

heddn’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new3.25 KB

Re-uploading a new version of #8 so we only test the actual patch, not the test only.

  • webchick committed 347624a on 9.0.x
    Issue #3095146 by Wim Leers, heddn: Drupal 7 date fields configured to...

  • webchick committed 6def62c on 8.9.x
    Issue #3095146 by Wim Leers, heddn: Drupal 7 date fields configured to...

  • webchick committed f7d549d on 8.8.x
    Issue #3095146 by Wim Leers, heddn: Drupal 7 date fields configured to...
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 9.0.x; 8.9.x; 8.8.x. Thanks!

webchick’s picture

Version: 8.9.x-dev » 8.8.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.