Commit 8b099542 authored by webchick's avatar webchick

Issue #3095195 by jofitz, Wim Leers, heddn: Drupal 7 date fields configured to...

Issue #3095195 by jofitz, Wim Leers, heddn: Drupal 7 date fields configured to not collect the hour/minute/second granularities can have "00" MM or DD attributes

(cherry picked from commit 92a0b41f)
parent f7d549d7
......@@ -127,6 +127,13 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
}
$settings = isset($this->configuration['settings']) ? $this->configuration['settings'] : [];
// Older versions of Drupal where omitting certain granularities (also known
// as "collected date attributes") resulted in invalid timestamps getting
// stored.
if ($fromFormat === 'Y-m-d\TH:i:s') {
$value = str_replace(['-00-00T', '-00T'], ['-01-01T', '-01T'], $value);
}
// Attempts to transform the supplied date using the defined input format.
// DateTimePlus::createFromFormat can throw exceptions, so we need to
// explicitly check for problems.
......
......@@ -229,6 +229,22 @@ public function datesDataProvider() {
'value' => '0000-00-00 00:00:00',
'expected' => '-0001-11-30 00:00:00',
],
'collected_date_attributes_day' => [
'configuration' => [
'from_format' => 'Y-m-d\TH:i:s',
'to_format' => 'Y-m-d\TH:i:s',
],
'value' => '2012-01-00T00:00:00',
'expected' => '2012-01-01T00:00:00',
],
'collected_date_attributes_month' => [
'configuration' => [
'from_format' => 'Y-m-d\TH:i:s',
'to_format' => 'Y-m-d\TH:i:s',
],
'value' => '2012-00-00T00:00:00',
'expected' => '2012-01-01T00:00:00',
],
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment