- Issue created by @joakland
- First commit to issue fork.
- Assigned to himanshu_jhaloya
- Issue was unassigned.
- Status changed to Needs review
10 months ago 5:56am 27 February 2024 - last update
10 months ago 11 pass, 2 fail - 🇮🇳India himanshu_jhaloya Indore
Created The patch Fixed the issue. Please review
The last submitted patch, 4: 3423941.patch, failed testing. View results →
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.- 🇧🇪Belgium BramDriesen Belgium 🇧🇪
You patch is not good, it's basically partially reverting what was added in 🐛 Time Field fails required field validation if value is 00:00 Needs work .
Furthermore, just tested this on D10.1.9 and for me this is working fine.
- Added a Time Range field to article (not required)
- Add content, only fill in title --> Save
- No issue
- Add content, fill in title, Start time 12:00, end time 00:00 --> Save
- No issue
- Add content, fill in title, Start time 00:00, end time 12:00 --> Save
- No issue
- Added a Time Range field to basic page (required)
- Add content, only fill in title --> Save --> Validation constraint (OK!)
- Add content, fill in title, Start time 12:00, end time 00:00 --> Save
- No issue
- Added content type
- Added a Time Range field to article (not required, multi value)
- Add content, only fill in title --> Save
- No issueDid you clear the cache after updating the module? Hiding the patch as it should not be used.
- Status changed to Postponed: needs info
10 months ago 7:56am 27 February 2024 - 🇺🇸United States joakland
Yes, I cleared the cache. You can see the results of my test in this screenshot:
Also, when I inspect the time field, I see that the input element has a default value that is not parsable:
- 🇺🇸United States joakland
Having discovered that the module is interpreting the timestamp of 86401 as empty, I was going to submit a patch, but I see there's a lot of logic built around using that timestamp to indicate an empty value. I'm curious about that decision. What's the thinking behind it? I'm going to hold off on submitting anything in the meantime.
- 🇧🇪Belgium BramDriesen Belgium 🇧🇪
The reasoning behind that was explained in https://www.drupal.org/project/time_field/issues/3074674#comment-14872771 ✨ Support empty time range values Fixed and https://www.drupal.org/project/time_field/issues/3074674#comment-14874717 ✨ Support empty time range values Fixed
I picked a value that would not normally be used. So 60 seconds * 60 minutes * 24 hours = 86400 seconds in a day.
I then added 1 to that value so that I knew it wasn't a valid value but could still be referenced. Probably better ways to do it but that was the original thought process.
What I don't understand is how that value ends up in your field as default value. Was this a node created before the upgrade? Also what version of Drupal?
- 🇧🇪Belgium BramDriesen Belgium 🇧🇪
Also just noticed that the field you're referring to in screenshot #9 is not a timerange field, but a time field with seconds.
- Assigned to BramDriesen
- Status changed to Active
10 months ago 7:07pm 27 February 2024 - 🇧🇪Belgium BramDriesen Belgium 🇧🇪
Ok so that's the issue. The field validation is not working for the regular time field. The tests I wrote only cover the timerange field.
- last update
10 months ago 11 pass, 2 fail - last update
10 months ago 11 pass, 2 fail - last update
10 months ago 11 pass, 2 fail - 🇺🇸United States joakland
Thanks for updating the empty field check logic, @BramDriesen. To answer your earlier questions (which you may not need now):
- No, this was a 100% new node
- I am using the most current version of Drupal, i.e. 10.2.3.
- last update
10 months ago 21 pass - 🇧🇪Belgium BramDriesen Belgium 🇧🇪
86401 is actually a valid timestamp, even if it's not likely to be used.
A valid timestamp yes, but not a valid time as it will fail in this function
Time::createFromTimestamp($value);
.It's been a while, but if I remember correctly, in order to allow empty values in the timerange widget, we needed a numeral value in order to do the in-range check. I remember trying to use NULL or empty string but could not get that to fit the validation logic and actually work.
- Status changed to Needs review
10 months ago 8:34pm 27 February 2024 - 🇳🇱Netherlands Jan-E
In my case (see related issue ✨ Support empty time range values Fixed ) it was also a time field. Moreover, it was intentionally hidden from some users by a hook_form_alter() statement:
$form['field_pmto_session_start_time']['widget']['#access'] = false;
Despite it being hidden the value that was entered into the database was 86401. No post-processing was done on the field, so I still do not know where the 86401 originated.
- 🇧🇪Belgium BramDriesen Belgium 🇧🇪
86401 was the new "empty" value being returned when nothing was filled in into the field. But the single timefield was not treating that value as empty resulting in the value getting saved.
Not sure if we need to add an update hook to clear the database of those entries.
- last update
10 months ago 21 pass - Status changed to Needs work
10 months ago 11:52am 28 February 2024 - 🇳🇱Netherlands Jan-E
I could reproduce the issue on a local copy of my site.
Then I applied your MR and did not run into the error 500 anymore.
If that count as RTBC, feel free to change the status.With respect to an update hook to clear the values: it would be a tricky one, because you cannot change every 86401 value into 0. You have to actually delete the field instance and possibly also a revision instance.
- Status changed to Needs review
10 months ago 11:52am 28 February 2024 -
BramDriesen →
committed c1cae857 on 2.x
Issue #3423941 by BramDriesen, joakland, Jan-E: After 2.1.1 update all...
-
BramDriesen →
committed c1cae857 on 2.x
- Status changed to Fixed
10 months ago 2:49pm 28 February 2024 - 🇧🇪Belgium BramDriesen Belgium 🇧🇪
Automatically closed - issue fixed for 2 weeks with no activity.