Closed (fixed)
Project:
Drupal core
Version:
10.2.x-dev
Component:
field system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 May 2019 at 22:39 UTC
Updated:
11 Nov 2023 at 14:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
baluertlComment #10
quietone commentedComment #11
quietone commentedLooking more closely at this, this is a duplicate of an earlier issue, #2838121: Numeric item min/max settings ignored if set to 0. The issue summary is well written and a search for duplicates was done, I'll move credit to the other issue.
Comment #14
quietone commentedI made a mistake. This is testing when the max is less than the min, so it is not a duplicate.
Also, un-assigning so everyone can work on this.
I closed #3327767: integer with minimum but no maximum causing ValueError: mt_rand(): Argument #2 ($max) must be greater than or equal to argument #1 ($min) as a duplicate, adding credit.
Comment #15
quietone commentedComment #16
joaopauloc.dev commentedComment #17
joaopauloc.dev commentedHello everyone, the patches above are attached and tested, and everything works fine.
Also, I added validation on the form field submission to validate min and max values.
Comment #18
joaopauloc.dev commentedComment #19
joaopauloc.dev commentedFixing php cs issues.
Comment #20
joaopauloc.dev commentedFixing php cs issues.
Comment #21
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
public static function validateMinMax1. can this be typehinted please
2. seems unintended
Did not test yet.
Comment #22
joaopauloc.dev commentedFixing type hint.
Comment #23
joaopauloc.dev commentedComment #24
kunalgautam commentedPatch #23 is applied and working fine for Drupal version 10.1.x. It can move for RTBC.
Comment #25
smustgrave commentedThank you @kkalashnikov but a screenshot of the patch does not provide value, we know that by the CI build. See https://www.drupal.org/about/core/policies/maintainers/how-is-credit-gra.... Removing credit for that.
Reviewing #23
Confirmed the fields mentioned in the IS does save invalid option (min: 4; max: -4)
Applied patch
Tested all the scenarios in the IS (integer, float, decimal) and I get a warning when trying to save those values.
Good work!
Comment #26
quietone commentedI took a look at the patch.
These changes are out of scope
These and the following should be incorporated into an existing test. There is no need to add additional setup costs for a functional test here.
Can we use the same field and not re-create one?
This should tell me what it does. See Coding standards for summary lines for more details.
The title should reflect what the function is doing. It isn't doing validation.
Comment #28
joaopauloc.dev commentedComment #29
joaopauloc.dev commentedComment #30
deepalij commentedAble to reproduce the issue using IS
Verified and tested MR #27 on Drupal 10.1.x-dev
The patch applied cleanly
The issue gets resolved after applying the patch.
Refer to the attached after patch screenshot
Comment #31
smustgrave commentedMoving back to RTBC. The changes in #26 appear to be addressed
26.1 = was removed
26.2 = helper function was removed and test simplified
26.3 = the test is existing so not sure we should update here
26.4 = help function was removed
Comment #32
quietone commentedThis is changing the UI, adding tag.
Comment #35
joaopauloc.dev commentedHello @quietone, I'm not sure if I understood or fixed the issues about moving the unit test to a kernel class.
Also, I didn't find any other way to test validateMinAndMaxConfig so I tested the method statically.
Maybe, we can also add the test back that I implemented in the other mr
Waiting for some feedback to update the code if necessary.
Comment #36
smustgrave commentedLeft a small comment on MR 4709 about adding an additional test set.
The kernel test looks good but don't see any reason to not include the additional asserts from MR 3436. If it were it's own function/bootstrap then maybe but that's expanding an existing tests. @quietone thoughts?
Comment #37
joaopauloc.dev commentedI added the test min 1 max 0.
Also, the Functional test with a tiny improvement where I added an assert to check the numbers as string values for the Integer type field. Now, as we have the kernel test I don't think we need to test for every number type. Just for integer is enough, but if you guys think is necessary I can add for each number field type.
Comment #38
smustgrave commentedSweet! Seems to address the failure from the previous MR.
Comment #39
xjmHiding patches; I just wasted 20 minutes reviewing an old thing. :P
Comment #40
xjmNW for many things as per my MR comments. Thanks everyone!
Comment #41
joaopauloc.dev commentedThis issue Field UI doesn't validate a field's default value on create is very similar, should I fix this issue here added as related issue or it's better to fix in another branch?
Working on code review comments
Comment #42
joaopauloc.dev commentedComment #44
smustgrave commentedSmall tweak.
Comment #45
joaopauloc.dev commentedComment #46
smustgrave commentedSeems feedback has been addressed!
Comment #47
xjmThanks @joaopauloc.dev and @smustgrave!
We should avoid
mixedif at all possible. PHP 8 supports union types so we can sayint|stringbased on the current test. (This fix includes an API addition and is therefore not backportable, so we don't need to worry about legacy PHP 7 compatibility for D9.)Interesting aside that does not actually affect the MR here -- note the behavior of int typehints with integer strings:
https://3v4l.org/LnQvW
Regarding #41, I added that to the related issues for now.
Comment #48
joaopauloc.dev commentedComment #49
smustgrave commentedThat was my mistake for suggesting it. Didn't know we wanted to avoid mixed but now I do!
Comment #50
quietone commentedFound a few things, commented in the MR. Of most concern is the behavior change which now prevents setting the min = max.
Comment #51
joaopauloc.dev commentedComment #52
smustgrave commentedThink this is good for RTBC again.
Comment #56
lauriiiCommitted 2ceafd0 and pushed to 11.x. Also cherry-picked to 10.2.x. Thanks!