Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In the prepare() method of DateMigrateFieldHandler in date.migrate.inc, the timezone of the items are never set. That is,
$return[$language][$delta]['value'] = $from;
if (!empty($to)) {
$return[$language][$delta]['value2'] = $to;
}
should be
$return[$language][$delta]['value'] = $from;
$return[$language][$delta]['timezone'] = $timezone;
if (!empty($to)) {
$return[$language][$delta]['value2'] = $to;
}
. A patch is attached.
I'm not completely familiar with the code, though. Instead of using $timezone
directly, should we use date_get_timezone($field_info['settings']['tz_handling'], $timezone);
?
As a side note, I noticed another bug while digging through the method. If a delta has a missing value, the function returns prematurely. It should set the NULL value for the delta, and continue the for loop. This is included in the patch below.
Comment | File | Size | Author |
---|---|---|---|
#1 | fixing-migrate-timezone-2408093-1.patch | 759 bytes | elephant.jim |
Comments
Comment #1
elephant.jim CreditAttribution: elephant.jim commentedAttaching a patch.
Comment #2
elephant.jim CreditAttribution: elephant.jim commentedComment #3
mikeryanSet your patches to "Needs review" for them to be tested and reviewed.
Comment #4
mikeryanThe solution to the timezone is exactly what I was going to do before I tracked down this issue. This does fix the timezone issue for me - can't speak to the delta issue (which should really be a separate d.o issue and patch).
Comment #5
heddnIs this a duplicate of #1888268: Date migrate generates undefined index 'timezone' notices?
Comment #6
joelstein CreditAttribution: joelstein commentedYep! This issue is fixed and is available in Date 7.x-2.9-rc1.
https://www.drupal.org/commitlog/commit/1810/f743b1bb45d27441751a62eec61...