Warning in \Drupal\Component\Datetime\DateTimePlus::checkArray()

Created on 7 October 2021, almost 4 years ago
Updated 13 February 2023, over 2 years ago

Problem/Motivation

I got warning when validating form with datelist element that have either year, month, or day in #date_text_parts option.

Warning: checkdate() expects parameter 1 to be int, string given in Drupal\Component\Datetime\DateTimePlus::checkArray() (line 624 of /var/www/d9-dev/core/lib/Drupal/Component/Datetime/DateTimePlus.php)

Steps to reproduce

  1. Make a form with datelist element like below:
      $form['datelist_test'] = [
        '#type' => 'datelist',
        '#title' => 'Datelist test',
        '#date_part_order' => ['year', 'month', 'day'],
        '#date_text_parts' => ['year', 'month', 'day'],
      ];
  2. Fill non-numeric text on a form and submit.

Proposed resolution

Check that each value in array is numeric before call checkdate() in DateTimePlus::checkArray() .

Remaining tasks

n/a

User interface changes

n/a

API changes

n/a

Data model changes

n/a

Release notes snippet

n/a

🐛 Bug report
Status

Needs work

Version

10.1

Component
Base 

Last updated about 3 hours ago

Created by

🇯🇵Japan hayashi

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024