The timestamp must be numeric

Created on 20 September 2023, about 1 year ago
Updated 9 July 2024, 5 months ago

Problem/Motivation

Steps to reproduce

  1. Install D10 base with 6.2.0-beta6 webform
  2. Create a webform with multi page
  3. Add Date field on Page 1
  4. Add another date field on Page 2
  5. Use the Date value of page 1 as the minimum or maximum value Date field on page 2 ([webform_submission:values:test_date])
  6. This throws "Unable to render elements, please view the below message(s) and the error log.
    The timestamp must be numeric." error.

Works fine on D9 and the installed Webform version is 6.1.4.

🐛 Bug report
Status

Fixed

Version

6.2

Component

Code

Created by

🇦🇺Australia Anil Thapa

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Anil Thapa
  • 🇮🇳India kasli_harshit

    Tried to reproduce the issue getting the same error (The timestamp must be numeric.) while working with D10 and webform 6.2.0-beta6 .
    However when i tried to reproduce the same in D9 and with webform 6.1.4 though we are able to save the webform fields and condition without any error . however we are not getting the desired result .

    Follow the same steps as mentioned in the issue with D9 and webform 6.1.4 , Set the page2 date field min value to date1 field value using (([webform_submission:values:date1_field_name]) . Now when we try to submit the response , the date validation for date2 is checking min value against the submission date of webform(today) instead of the date1 field value which is not the ideal behaviour.

    Adding the screenshot for the same.

  • 🇺🇸United States jrockowitz Brooklyn, NY
  • 🇺🇸United States jrockowitz Brooklyn, NY

    So the below YAML source when pasted into a D10 6.2.x webform trigger the error

    page_01:
      '#type': wizard_page
      '#title': page_01
      date_01:
        '#type': date
        '#title': date_01
    page_02:
      '#type': wizard_page
      '#title': page_02
      date_02:
        '#type': date
        '#title': date_02
        '#date_date_min': '[webform_submission:values:date_01]'
    
  • 🇺🇸United States jrockowitz Brooklyn, NY

    I was not able to track down the root cause of the regression but the attached patch is reasonable and safe fix to immediate issue and is unlikely to cause additional regressions.

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    535 pass
  • 🇺🇸United States jrockowitz Brooklyn, NY
  • 🇮🇳India kasli_harshit

    @jrockowitz i tried to applied the patch(#7) , after applying the patch although we are successfully able to save webform with the conditions on the date field , however we are still getting same error now upon submission of the webform. Attaching the screenshot for reference .

  • Status changed to Needs work about 1 year ago
  • 🇺🇸United States jrockowitz Brooklyn, NY
  • 🇺🇸United States jrockowitz Brooklyn, NY

    The error is originating from \Drupal\Component\Datetime\DateTimePlus::createFromTimestamp

  • 🇺🇸United States jrockowitz Brooklyn, NY

    A slightly better approach where all invalid element date properties will unset. This approach can be used to prevent other date-related regressions.

    This patch should also be applied to 6.1.x

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    Patch Failed to Apply
  • 🇺🇸United States jrockowitz Brooklyn, NY
  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.2 & MySQL 8
    last update about 1 year ago
    Composer require failure
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update about 1 year ago
    536 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    Patch Failed to Apply
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    Patch Failed to Apply
  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    The patch will stop the "timestamp must be numeric" errors. But is this field supposed to be able to support tokens? Should it set an error message when it encounters an invalid value in one of the four properties that it checks?

  • 🇺🇸United States jrockowitz Brooklyn, NY

    The tokens are replaced via parent::prepare($element, $webform_submission).

    If the tokens are NOT replaced, they are invalid, so they should be removed.

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    OK, so you're saying that any valid tokens will have already been replaced? That makes sense. In that case, this patch makes sense to me.

  • Status changed to Fixed about 1 year ago
  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • 🇮🇳India Rohit Tiwari

    I am getting the same issue still on same scenario as mentioned in the issue summary.

    My setup is:
    Drupal: 9.5.8
    Webform: 6.2.3

    Error: InvalidArgumentException: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 201 of /mnt/www/html/trimedcmsej6ddn8fnr/docroot/core/lib/Drupal/Component/Datetime/DateTimePlus.php).

  • Status changed to Fixed 5 months ago
  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    What property is causing the problem? Maybe something else needs to be added to $date_properties.

  • 🇮🇳India Rohit Tiwari

    This is the YML causing issue:

    published_dates:
        '#type': flexbox
        publish_date:
          '#type': datetime
          '#title': 'Publish Date'
          '#date_date_min': TODAY
          '#date_date_format': ''
          '#date_time_format': ''
          '#date_time_step': '60'
          '#required': true
        unpublish_date:
          '#type': datetime
          '#title': 'Unpublish Date (if any)'
          '#date_date_min': '[webform_submission:values:publish_date]'
          '#date_date_format': ''
          '#date_time_format': ''
          '#date_time_step': '60'
  • 🇵🇹Portugal jrochate

    I'm also having this problem:

    webform 6.2.x
    drupal 10.3

        data_evento_inicio:
          '#type': datetime
          '#title': 'Data do Evento'
          '#title_display': inline
          '#required': true
          '#format': simple_datetime_alt
          '#date_year_range': ''
        data_evento_fim:
          '#type': datetime
          '#title': Fim
          '#title_display': inline
          '#required': true
          '#date_min': '[webform_submission:values:data_evento_inicio:raw]'
          '#format': simple_datetime_alt
          '#date_year_range': ''

    I think the best is to use raw as should result in an UNIXTIMESTAMP.

    But I'm getting the error:

    Unable to render elements, please view the below message(s) and the error log.

    The timestamp must be numeric.

    Is it impossible to reference previous submissions fields on this validation rule?

    Can't find out the limitation. TIA

Production build 0.71.5 2024