Problem/Motivation

php date returns a string also for numeric formats. Checkdate returns an error because of this.

Steps to reproduce

- Generate a new code while providing from/to dates
- Php error is returned on php 8.3

Proposed resolution

Will provide patch/MR

Remaining tasks

Provide patch

User interface changes

API changes

None

Data model changes

None

Issue fork regcode-3480519

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jb044 created an issue. See original summary.

tr’s picture

Status: Active » Needs work
Issue tags: +Needs tests

I would like so see something more than a cast here. That form element was inherited from Drupal 7 and not updated for Drupal 8+, and the way it is handling dates is not what we do in Drupal these days.

For example, a default value of an array, and parsing the string with strtotime(), which isn't necessary because the front-end date picker delivers a fixed format. So the description of what to enter is wrong too.

I would like to update these '#type' => 'date' form elements, and add a test case to make sure that values can be entered in this form and submitted without an error. There is a test case that will be put in as part of #3476179: Route "regcode.admin_list" does not exist which just verifies that the form page can be accessed, but that should be modified to fill out the form and submit it as well. For all the tabs.

Can you work on this?

jb044’s picture

I'm a bit uncertain what test case(s) to add since a html5 date form element does not seem to accept an invalid date. Also I found yet another flaw that since then appears to have been fixed already: both regcode_create_number and regcode_create_case need to be typecasted as integer and boolean for the code to work. You could argue that "create number" should be a number then for it to not be passed as a string, but I don't think that would be very user friendly. That is I dislike html5 toggle up/down elements :)

Please let me know if this still needs work with test cases.

Also a bit offtopic but still relevant: for 2.0.0 the patches are piling up, when can we expect another stable point release?

tr’s picture

As far as the test, what I had in mind is to modify RegcodeSettingsTest to add a new test case which does drupalGet('admin/config/people/regcode/settings') then sets values for all the fields, then does submitForm(). Nothing more than that - that would have been enough to detect this issue that you reported because the test would have failed with the error you reported.

Also I found yet another flaw that since then appears to have been fixed already: both regcode_create_number and regcode_create_case need to be typecasted as integer and boolean for the code to work.

Yes, I did some general work trying to fix typing problems. I would really like to get these form settings into configuration, so that the entered values can be remembered and used as the defaults - I find it annoying that every time I go to this form I have to enter all the values and make all the selections over again because it doesn't remember my previous entries.

I think the only outstanding issues I wanted to get in before the next release are #3476179: Route "regcode.admin_list" does not exist and #3227669: Display all users which used the current regcode., in addition to this current issue.

jb044’s picture

Status: Needs work » Needs review

  • tr committed 300397b8 on 2.0.x authored by jb044
    Issue #3480519 by jb044: checkdate error, int expected string provided
    
tr’s picture

Status: Needs review » Fixed

Very nice. Thank you! Merged.

Status: Fixed » Closed (fixed)

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