Uncaught exception 'TypeError' with message 'checkdate(): Argument #3 ($year) must be of type int, string given

Created on 3 November 2022, over 1 year ago
Updated 7 June 2024, 12 days ago

API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Date...

Problem/Motivation

if (!empty($array['year']) && !empty($array['month']) && !empty($array['day'])) {
      $valid_date = checkdate((int)$array['month'], (int)$array['day'], (int)$array['year']);
    }

The $array['month'], $array['day'], $array['year'] values are not guaranteed to be integers and they should be. In PHP8 this causes test failures.

This error is produced when running on new relic.

Proposed resolution

Casting each value to an integer works but not sure it consider as a best fixes.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Documentation 

Last updated about 2 hours ago

No maintainer
Created by

🇮🇳India sumeet-biswal

Live updates comments and jobs are added and updated live.
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.

  • 🇮🇳India Ranjit1032002

    Created a patch with Interdiff and also fixes custom commands, please review.
    Thank You.

  • 🇺🇸United States smustgrave

    @Ranjit1032002 thank you for the interest but you've been working on a number of these tickets now. Adding just a check isn't usually a good solution. As it could be hiding a deeper issue.

    If steps are not provided to reproduce that will be needed.

    This error is produced when running on new relic.

    Can someone please elaborate more.

    As a bug it will need a test case.

    Please do some checks before putting into review to receive credit.

    Thanks

    Also removing credit for #2 for an empty commit

  • Status changed to Needs work about 1 year ago
  • 🇯🇵Japan Skyyade

    The reproduction procedure is as follows
    1. create a form element of type 'datelist' with FormAPI.
    2. Display the screen and use the developer tools to change the value from a number to a string. (Example: 1900 -> aaa)
    3. submit the form and get a 500 error for the Issue in question.

    We believe this should be fixed during 10.3.

  • 🇺🇸United States Luke.Leber Pennsylvania

    So the reproduction steps include needing an end-user to tamper with a request outside of the normal user agent controls? If that's the case, I'm not quite sure it qualifies for a critical triage. Sliding back down to normal. If there's a way for an end-user to hit this without request tampering, please feel free to re-triage accordingly!

    Agreed it needs a new test case and some additional logic to check not only for emptiness, but data type. A single new case should do the trick.

  • 🇺🇸United States xjm

    Issues go into 11.x first unless they are confirmed to be D10-only. Please don't change the branch without a specific reason related to the issue's development. Thanks!

Production build 0.69.0 2024