Skip to content
Snippets Groups Projects
Commit 92a0b41f authored by Angie Byron's avatar Angie Byron
Browse files

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
parent 347624ad
Branches
Tags
6 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards
......@@ -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',
],
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment