updated core from 8.4 to 8.5 : bug with login_destination

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-13 14:01:21 +01:00
parent 0d78da249b
commit e668535a4e
3486 changed files with 89604 additions and 33283 deletions
@@ -7,8 +7,8 @@ package: Field types
dependencies:
- datetime
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457826
@@ -8,6 +8,7 @@ use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemList;
use Drupal\Core\Form\FormStateInterface;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeFieldItemList;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
/**
* Represents a configurable entity daterange field.
@@ -105,18 +106,18 @@ class DateRangeFieldItemList extends DateTimeFieldItemList {
// only provide a default value for the first item, as do all fields.
// Otherwise, there is no way to clear out unwanted values on multiple
// value fields.
$storage_format = $definition->getSetting('datetime_type') == DateRangeItem::DATETIME_TYPE_DATE ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT;
$storage_format = $definition->getSetting('datetime_type') == DateRangeItem::DATETIME_TYPE_DATE ? DateTimeItemInterface::DATE_STORAGE_FORMAT : DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
$default_values = [[]];
if (!empty($default_value[0]['default_date_type'])) {
$start_date = new DrupalDateTime($default_value[0]['default_date'], DATETIME_STORAGE_TIMEZONE);
$start_date = new DrupalDateTime($default_value[0]['default_date'], DateTimeItemInterface::STORAGE_TIMEZONE);
$start_value = $start_date->format($storage_format);
$default_values[0]['value'] = $start_value;
$default_values[0]['start_date'] = $start_date;
}
if (!empty($default_value[0]['default_end_date_type'])) {
$end_date = new DrupalDateTime($default_value[0]['default_end_date'], DATETIME_STORAGE_TIMEZONE);
$end_date = new DrupalDateTime($default_value[0]['default_end_date'], DateTimeItemInterface::STORAGE_TIMEZONE);
$end_value = $end_date->format($storage_format);
$default_values[0]['end_value'] = $end_value;
$default_values[0]['end_date'] = $end_date;
@@ -8,6 +8,7 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\datetime\DateTimeComputed;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
/**
* Plugin implementation of the 'daterange' field type.
@@ -96,12 +97,12 @@ class DateRangeItem extends DateTimeItem {
$start = REQUEST_TIME - mt_rand(0, 86400 * 365) - 86400;
$end = $start + 86400;
if ($type == static::DATETIME_TYPE_DATETIME) {
$values['value'] = gmdate(DATETIME_DATETIME_STORAGE_FORMAT, $start);
$values['end_value'] = gmdate(DATETIME_DATETIME_STORAGE_FORMAT, $end);
$values['value'] = gmdate(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $start);
$values['end_value'] = gmdate(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $end);
}
else {
$values['value'] = gmdate(DATETIME_DATE_STORAGE_FORMAT, $start);
$values['end_value'] = gmdate(DATETIME_DATE_STORAGE_FORMAT, $end);
$values['value'] = gmdate(DateTimeItemInterface::DATE_STORAGE_FORMAT, $start);
$values['end_value'] = gmdate(DateTimeItemInterface::DATE_STORAGE_FORMAT, $end);
}
return $values;
}
@@ -5,7 +5,7 @@ namespace Drupal\datetime_range\Plugin\Field\FieldWidget;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\datetime\Plugin\Field\FieldWidget\DateTimeWidgetBase;
use Drupal\datetime_range\Plugin\Field\FieldType\DateRangeItem;
@@ -58,10 +58,7 @@ class DateRangeWidgetBase extends DateTimeWidgetBase {
$start_date = $item['value'];
switch ($this->getFieldSetting('datetime_type')) {
case DateRangeItem::DATETIME_TYPE_DATE:
// If this is a date-only field, set it to the default time so the
// timezone conversion can be reversed.
datetime_date_default_time($start_date);
$format = DATETIME_DATE_STORAGE_FORMAT;
$format = DateTimeItemInterface::DATE_STORAGE_FORMAT;
break;
case DateRangeItem::DATETIME_TYPE_ALLDAY:
@@ -71,15 +68,15 @@ class DateRangeWidgetBase extends DateTimeWidgetBase {
// we need to explicitly set the timezone.
$start_date->setTimeZone(timezone_open(drupal_get_user_timezone()));
$start_date->setTime(0, 0, 0);
$format = DATETIME_DATETIME_STORAGE_FORMAT;
$format = DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
break;
default:
$format = DATETIME_DATETIME_STORAGE_FORMAT;
$format = DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
break;
}
// Adjust the date for storage.
$start_date->setTimezone(new \DateTimezone(DATETIME_STORAGE_TIMEZONE));
$start_date->setTimezone(new \DateTimezone(DateTimeItemInterface::STORAGE_TIMEZONE));
$item['value'] = $start_date->format($format);
}
@@ -88,10 +85,7 @@ class DateRangeWidgetBase extends DateTimeWidgetBase {
$end_date = $item['end_value'];
switch ($this->getFieldSetting('datetime_type')) {
case DateRangeItem::DATETIME_TYPE_DATE:
// If this is a date-only field, set it to the default time so the
// timezone conversion can be reversed.
datetime_date_default_time($end_date);
$format = DATETIME_DATE_STORAGE_FORMAT;
$format = DateTimeItemInterface::DATE_STORAGE_FORMAT;
break;
case DateRangeItem::DATETIME_TYPE_ALLDAY:
@@ -101,15 +95,15 @@ class DateRangeWidgetBase extends DateTimeWidgetBase {
// we need to explicitly set the timezone.
$end_date->setTimeZone(timezone_open(drupal_get_user_timezone()));
$end_date->setTime(23, 59, 59);
$format = DATETIME_DATETIME_STORAGE_FORMAT;
$format = DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
break;
default:
$format = DATETIME_DATETIME_STORAGE_FORMAT;
$format = DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
break;
}
// Adjust the date for storage.
$end_date->setTimezone(new \DateTimezone(DATETIME_STORAGE_TIMEZONE));
$end_date->setTimezone(new \DateTimezone(DateTimeItemInterface::STORAGE_TIMEZONE));
$item['end_value'] = $end_date->format($format);
}
}
@@ -142,30 +136,4 @@ class DateRangeWidgetBase extends DateTimeWidgetBase {
}
}
/**
* Creates a date object for use as a default value.
*
* This will take a default value, apply the proper timezone for display in
* a widget, and set the default time for date-only fields.
*
* @param \Drupal\Core\Datetime\DrupalDateTime $date
* The UTC default date.
* @param string $timezone
* The timezone to apply.
*
* @return \Drupal\Core\Datetime\DrupalDateTime
* A date object for use as a default value in a field widget.
*/
protected function createDefaultValue($date, $timezone) {
// The date was created and verified during field_load(), so it is safe to
// use without further inspection.
if ($this->getFieldSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE) {
// A date without time will pick up the current time, use the default
// time.
datetime_date_default_time($date);
}
$date->setTimezone(new \DateTimeZone($timezone));
return $date;
}
}
@@ -6,6 +6,7 @@ use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Datetime\Entity\DateFormat;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\Tests\datetime\Functional\DateTestBase;
use Drupal\datetime_range\Plugin\Field\FieldType\DateRangeItem;
use Drupal\entity_test\Entity\EntityTest;
@@ -110,8 +111,8 @@ class DateRangeFieldTest extends DateTestBase {
// Formats that display a time component for date-only fields will display
// the default time, so that is applied before calculating the expected
// value.
datetime_date_default_time($start_date);
datetime_date_default_time($end_date);
$this->massageTestDate($start_date);
$this->massageTestDate($end_date);
// Reset display options since these get changed below.
$this->displayOptions = [
@@ -128,11 +129,11 @@ class DateRangeFieldTest extends DateTestBase {
->setComponent($field_name, $this->displayOptions)
->save();
$start_expected = $this->dateFormatter->format($start_date->getTimestamp(), 'long', '', DATETIME_STORAGE_TIMEZONE);
$start_expected_iso = $this->dateFormatter->format($start_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DATETIME_STORAGE_TIMEZONE);
$start_expected = $this->dateFormatter->format($start_date->getTimestamp(), 'long', '', DateTimeItemInterface::STORAGE_TIMEZONE);
$start_expected_iso = $this->dateFormatter->format($start_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DateTimeItemInterface::STORAGE_TIMEZONE);
$start_expected_markup = '<time datetime="' . $start_expected_iso . '" class="datetime">' . $start_expected . '</time>';
$end_expected = $this->dateFormatter->format($end_date->getTimestamp(), 'long', '', DATETIME_STORAGE_TIMEZONE);
$end_expected_iso = $this->dateFormatter->format($end_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DATETIME_STORAGE_TIMEZONE);
$end_expected = $this->dateFormatter->format($end_date->getTimestamp(), 'long', '', DateTimeItemInterface::STORAGE_TIMEZONE);
$end_expected_iso = $this->dateFormatter->format($end_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DateTimeItemInterface::STORAGE_TIMEZONE);
$end_expected_markup = '<time datetime="' . $end_expected_iso . '" class="datetime">' . $end_expected . '</time>';
$output = $this->renderTestEntity($id);
$this->assertContains($start_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute in %timezone.', [
@@ -160,7 +161,7 @@ class DateRangeFieldTest extends DateTestBase {
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $start_date->format(DATETIME_DATE_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATE_STORAGE_FORMAT);
$expected = $start_date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT) . ' - ' . $end_date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT);
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected in %timezone.', [
'%expected' => $expected,
@@ -211,7 +212,7 @@ class DateRangeFieldTest extends DateTestBase {
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
datetime_date_default_time($start_date);
$this->massageTestDate($start_date);
$this->displayOptions = [
'type' => 'daterange_default',
@@ -226,8 +227,8 @@ class DateRangeFieldTest extends DateTestBase {
->setComponent($field_name, $this->displayOptions)
->save();
$start_expected = $this->dateFormatter->format($start_date->getTimestamp(), 'long', '', DATETIME_STORAGE_TIMEZONE);
$start_expected_iso = $this->dateFormatter->format($start_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DATETIME_STORAGE_TIMEZONE);
$start_expected = $this->dateFormatter->format($start_date->getTimestamp(), 'long', '', DateTimeItemInterface::STORAGE_TIMEZONE);
$start_expected_iso = $this->dateFormatter->format($start_date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DateTimeItemInterface::STORAGE_TIMEZONE);
$start_expected_markup = '<time datetime="' . $start_expected_iso . '" class="datetime">' . $start_expected . '</time>';
$output = $this->renderTestEntity($id);
$this->assertContains($start_expected_markup, $output, new FormattableMarkup('Formatted date field using %value format displayed as %expected with %expected_iso attribute in %timezone.', [
@@ -248,7 +249,7 @@ class DateRangeFieldTest extends DateTestBase {
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $start_date->format(DATETIME_DATE_STORAGE_FORMAT);
$expected = $start_date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT);
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected in %timezone.', [
'%expected' => $expected,
@@ -352,7 +353,7 @@ class DateRangeFieldTest extends DateTestBase {
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$expected = $start_date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT) . ' - ' . $end_date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
@@ -428,7 +429,7 @@ class DateRangeFieldTest extends DateTestBase {
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$expected = $start_date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
$this->assertNotContains(' THESEPARATOR ', $output, 'Separator not found on page');
@@ -520,7 +521,7 @@ class DateRangeFieldTest extends DateTestBase {
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' - ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$expected = $start_date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT) . ' - ' . $end_date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
@@ -598,7 +599,7 @@ class DateRangeFieldTest extends DateTestBase {
entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full')
->setComponent($field_name, $this->displayOptions)
->save();
$expected = $start_date->format(DATETIME_DATETIME_STORAGE_FORMAT) . ' THESEPARATOR ' . $end_date->format(DATETIME_DATETIME_STORAGE_FORMAT);
$expected = $start_date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT) . ' THESEPARATOR ' . $end_date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);
$output = $this->renderTestEntity($id);
$this->assertContains($expected, $output, new FormattableMarkup('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected]));
$this->assertContains(' THESEPARATOR ', $output, 'Found proper separator');
@@ -1020,9 +1021,9 @@ class DateRangeFieldTest extends DateTestBase {
// Create a new node to check that datetime field default value is today.
$new_node = Node::create(['type' => 'date_content']);
$expected_date = new DrupalDateTime('now', DATETIME_STORAGE_TIMEZONE);
$this->assertEqual($new_node->get($field_name)->offsetGet(0)->value, $expected_date->format(DATETIME_DATE_STORAGE_FORMAT));
$this->assertEqual($new_node->get($field_name)->offsetGet(0)->end_value, $expected_date->format(DATETIME_DATE_STORAGE_FORMAT));
$expected_date = new DrupalDateTime('now', DateTimeItemInterface::STORAGE_TIMEZONE);
$this->assertEqual($new_node->get($field_name)->offsetGet(0)->value, $expected_date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT));
$this->assertEqual($new_node->get($field_name)->offsetGet(0)->end_value, $expected_date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT));
// Set an invalid relative default_value to test validation.
$field_edit = [
@@ -1073,10 +1074,10 @@ class DateRangeFieldTest extends DateTestBase {
// Create a new node to check that datetime field default value is +90 days.
$new_node = Node::create(['type' => 'date_content']);
$expected_start_date = new DrupalDateTime('+45 days', DATETIME_STORAGE_TIMEZONE);
$expected_end_date = new DrupalDateTime('+90 days', DATETIME_STORAGE_TIMEZONE);
$this->assertEqual($new_node->get($field_name)->offsetGet(0)->value, $expected_start_date->format(DATETIME_DATE_STORAGE_FORMAT));
$this->assertEqual($new_node->get($field_name)->offsetGet(0)->end_value, $expected_end_date->format(DATETIME_DATE_STORAGE_FORMAT));
$expected_start_date = new DrupalDateTime('+45 days', DateTimeItemInterface::STORAGE_TIMEZONE);
$expected_end_date = new DrupalDateTime('+90 days', DateTimeItemInterface::STORAGE_TIMEZONE);
$this->assertEqual($new_node->get($field_name)->offsetGet(0)->value, $expected_start_date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT));
$this->assertEqual($new_node->get($field_name)->offsetGet(0)->end_value, $expected_end_date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT));
// Remove default value.
$field_edit = [
@@ -1110,7 +1111,7 @@ class DateRangeFieldTest extends DateTestBase {
])
->save();
$expected_date = new DrupalDateTime('now', DATETIME_STORAGE_TIMEZONE);
$expected_date = new DrupalDateTime('now', DateTimeItemInterface::STORAGE_TIMEZONE);
$field_edit = [
'default_value_input[default_date_type]' => 'now',
@@ -1120,7 +1121,7 @@ class DateRangeFieldTest extends DateTestBase {
// Make sure only the start value is populated on node add page.
$this->drupalGet('node/add/date_content');
$this->assertFieldByName("{$field_name}[0][value][date]", $expected_date->format(DATETIME_DATE_STORAGE_FORMAT), 'Start date element populated.');
$this->assertFieldByName("{$field_name}[0][value][date]", $expected_date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT), 'Start date element populated.');
$this->assertFieldByName("{$field_name}[0][end_value][date]", '', 'End date element empty.');
// Set now as default_value for end date only.
@@ -1133,7 +1134,7 @@ class DateRangeFieldTest extends DateTestBase {
// Make sure only the start value is populated on node add page.
$this->drupalGet('node/add/date_content');
$this->assertFieldByName("{$field_name}[0][value][date]", '', 'Start date element empty.');
$this->assertFieldByName("{$field_name}[0][end_value][date]", $expected_date->format(DATETIME_DATE_STORAGE_FORMAT), 'End date element populated.');
$this->assertFieldByName("{$field_name}[0][end_value][date]", $expected_date->format(DateTimeItemInterface::DATE_STORAGE_FORMAT), 'End date element populated.');
}
/**
@@ -100,6 +100,8 @@ class DateRangeItemTest extends FieldKernelTestBase {
sleep(1);
$end_date = $entity->{$field_name}->end_date;
$this->assertEquals($start_date->getTimestamp(), $end_date->getTimestamp());
$this->assertEquals('12:00:00', $start_date->format('H:i:s'));
$this->assertEquals('12:00:00', $end_date->format('H:i:s'));
}
}