Fix regression that not allow to use a custom filter with subform field#27561
Fix regression that not allow to use a custom filter with subform field#27561rdeutz merged 3 commits intojoomla:stagingfrom
Conversation
|
I have tested this item ✅ successfully on da9a1bb This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27561. |
1 similar comment
|
I have tested this item ✅ successfully on da9a1bb This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27561. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/27561. |
|
@joomla/security please review this as this addressed a specific vulnerability in the past |
| $subForm = $field->loadSubForm(); | ||
|
|
||
| if ($field->multiple) | ||
| if ($field->multiple && $value) |
There was a problem hiding this comment.
What is the intention of this change? We might should check whether this is an array right?
There was a problem hiding this comment.
It can be an array or an object.
There was a problem hiding this comment.
What is the intention of this change
if there a no value you will get an php notice while foreach(null as $key => $val)
There was a problem hiding this comment.
OK then let's do is_array here and can we add a comment just explaining it covers an optional subform field
There was a problem hiding this comment.
Would probably need is_array() and is_object() in that case. This check also needs to be nested to avoid issues. See #27671.
There was a problem hiding this comment.
it does not make much sense, because if you see whole condition, it still will be validated
joomla-cms/libraries/src/Form/Form.php
Lines 2158 to 2176 in da9a1bb
filter already have the same conditions
joomla-cms/libraries/src/Form/Form.php
Lines 1567 to 1579 in da9a1bb
There was a problem hiding this comment.
The entire concept of validating an empty value seems weird to me :)
There was a problem hiding this comment.
yeah, but that what we have ;)
There was a problem hiding this comment.
It won't be validated if you follow #27671. Apply same changes to filter.
|
@joel-lupfer @SniperSister Any additional input here? |
|
@joel-lupfer @SniperSister Any additional input here? |
|
@richard67 fine for me! |
Summary of Changes
Fix regression that not allow to use a custom filter with subform field, was introduced by one of previous update.
Testing Instructions
Apply patch, create a subform field , somwhere in CustomHTML module, with custom filter:
Add custom filter class, somwhere in bottom of
plugins/system/debug/debug.php:Then create a Custom module in backed, and try save it.
Look for the message you got
Expected result
You should get 2 message:
Filter works: {"test_fields0":{"test_field":""}}and
Module savedActual result
You get 1 message
Module savedthat means the custom filter was ignored