-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
cast variable #27618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cast variable #27618
Conversation
|
I have tested this item ✅ successfully on ecb7260 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27618. |
1 similar comment
|
I have tested this item ✅ successfully on ecb7260 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27618. |
|
Strange, I am able to reproduce with v3.9.15 today. |
|
Sorry false alarm. I had applied your PR when testing. Duh! To me, it feels hackish fix. |
|
You are right, this is hackish! The problem is that Do you like my new version better? |
|
Now it is always invalid. |
|
@Quy The last change is embarrassing to me. Now it should fit. The following things are considered to be empty (https://www.php.net/empty):
If I am correct, we have to treat the case string "0" differently. |
|
@N6REJ I would be happy if you could test again |
| $required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required'); | ||
|
|
||
| if (!$required && empty($value)) | ||
| if (!$required && empty($value) && !($data['default_value'] !== "0")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$data is undefined here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, corrected
|
Requested updates are done. |
|
I have tested this item ✅ successfully on 8a61ac9 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27618. |
|
Having a closer look, integer 0 and float 0.0 should also pass. So it would probably be better to compare against actually empty values ( |
I hope I understand you correctly. Do you mean this?
You're right. If I find a solution here that is good, I would look at more. I think it makes this PR more complicated if I try to includ this here. |
|
This issue affects core form validation rules, so not just custom fields but any forms using them. |
|
@SharkyKZ I do not understand what you mean. I know that this rule does not just apply to custom fields. |
|
I haven't tested it but what's about |
|
|
OK. Now I saw it. But I think we can use the What do you all mean? |
|
This doesn't cover negative values. If you want to keep logic this way, use |
|
What is not covered? |
|
No, you're right. My bad. This works fine. |
This test is irrelevant! My fault.I have tested this item 🔴 unsuccessfully on 3ccf188 Radio Value: 1 => 1 Default Values: "Save failed with the following error: The default value is invalid." This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27618. |
|
I have tested this item ✅ successfully on 3ccf188 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27618. |
|
I have tested this item ✅ successfully on 3ccf188 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27618. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27618. |
|
Thanks |


Pull Request for Issue in the German forum.
Summary of Changes
Cast a default Custom Field value of
0to-0.Testing Instructions
0but add no value with0.Expected result
You see an error if you want to save a custom field with a default value, that is not possible.
Actual result
Saving is possible.
Documentation Changes Required
No
Note
I cast this value because the function empty is used twice: Here and here in the function
test.