Problem/Motivation

Split from #2921810: Allow TimestampFormatter to show as a fully cacheable time difference with JS as being a standalone issue.

Timestamp field misses schema for value: field.value.timestamp.

Note that storage and field settings are covered by the fallback schema:

  • field.storage_settings.timestamp resolved by field.storage_settings.*
  • field.field_settings.timestamp resolved by field.field_settings.*

Proposed resolution

Add schema in core/config/schema/core.data_types.schema.yml.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new590 bytes

Fix.

venkatesh rajan.j’s picture

Assigned: Unassigned » venkatesh rajan.j
venkatesh rajan.j’s picture

Assigned: venkatesh rajan.j » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new23.38 KB
new59.03 KB

@claudiu.cristea,

Thanks for the patch. Your patch applied cleanly. PFA for the same.

Schema for timestamp has been added core.data_types.schema.yml file

wim leers’s picture

Component: datetime.module » field system

This doesn't live in the datetime module.

@Venkatesh Rajan.J: posting screenshots of a succesfully applying patch is not useful. The fact that tests passed already prove that the patch applies successfully.

wim leers’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Entity Field API
+++ b/core/config/schema/core.data_types.schema.yml
@@ -743,6 +743,16 @@ field.value.float:
+      type: integer

Actually, this is not just a integer, it's a UNIX timestamp. Which for example means it can't go negative.

i.e. the current config schema refers to:

integer:
  label: 'Integer'
  class: '\Drupal\Core\TypedData\Plugin\DataType\IntegerData'

But this value is actually \Drupal\Core\TypedData\Plugin\DataType\Timestamp.

Because:

class TimestampItem extends FieldItemBase {

  /**
   * {@inheritdoc}
   */
  public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    $properties['value'] = DataDefinition::create('timestamp')
      ->setLabel(t('Timestamp value'))
      ->setRequired(TRUE);
    return $properties;
  }
mpdonadio’s picture

Actually, this is not just a integer, it's a UNIX timestamp. Which for example means it can't go negative.

If a system support signed `time_t`, then timestamps can be negative. A negative number represents date/times before 1970-01-01 (see some of the issues about timestamps and the 1901 problem). The 2038 problem is 2^31-1, rolling over into 1901. The Wikipedia article has some more details.

I'm wondering if we need a decent way to detect missing schema definitions. Maybe a meta parent issue to remove most of the wildcards so we can detect problems?

wim leers’s picture

Maybe a meta parent issue to remove most of the wildcards so we can detect problems?

+1

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new592 bytes
new438 bytes

Actually, this is not just a integer, it's a UNIX timestamp.

@Wim Leers, Great, I totally missed that data type.

borisson_’s picture

+++ b/core/config/schema/core.data_types.schema.yml
@@ -757,6 +757,16 @@ field.value.float:
+# Schema for the configuration of the Timestamp field type.
+
+field.value.timestamp:

I don't think the blank line there is needed.

claudiu.cristea’s picture

I don't think the blank line there is needed.

Me neither but I followed the pattern used in the rest of the file.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs followup

Needs follow-up for #7/#8. But this patch is ready.

larowlan’s picture

Adding review credit for @Wim Leers for reviews that shaped the patch

  • larowlan committed 1872e83 on 8.5.x
    Issue #2931294 by claudiu.cristea, Wim Leers: Timestamp field type...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed 1872e83 and pushed to 8.5.x.

Cherry-picked as c671146 and pushed to 8.4.x

  • larowlan committed c671146 on 8.4.x
    Issue #2931294 by claudiu.cristea, Wim Leers: Timestamp field type...
larowlan’s picture

Can we get the follow-up for #7 and #8?

Thanks

mpdonadio’s picture

Status: Fixed » Closed (fixed)

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

claudiu.cristea’s picture

Unfortunately, we forgot here to define the timestamp scalar data type. For this reason any test that is trying to import a field.field.*.* configuration for a timestamp field will fail. I've opened a followup to fix this bug in #2938799: Provide the timestamp scalar data type.