If Conditions - IN checks for string not array

healyhatman 13 Jul, 2019
Answer
1 Likes
As per title, the If Conditions action's "IN" and "NOT IN" conditions check if the value exists within a STRING only, and doesn't check if the value exists in a given array.

E.g.
Check for 0 IN {value:[0,1]} gives you
Warning: explode() expects parameter 2 to be string, array given in C:\xampp\htdocs\dev\libraries\cegcore2\admin\extensions\chronofc\functions\if_conditions\if_conditions_output.phpon line28
Warning: array_map(): Argument #2 should be an array in C:\xampp\htdocs\dev\libraries\cegcore2\admin\extensions\chronofc\functions\if_conditions\if_conditions_output.phpon line28
Warning: array_filter() expects parameter 1 to be array, null given in C:\xampp\htdocs\dev\libraries\cegcore2\admin\extensions\chronofc\functions\if_conditions\if_conditions_output.phpon line28
Warning: in_array() expects parameter 2 to be array, null given in C:\xampp\htdocs\dev\libraries\cegcore2\admin\extensions\chronofc\functions\if_conditions\if_conditions_output.phpon line29
Because the code is
 $second = array_filter(array_map('trim', explode("\n", $second)), 'strlen');
return in_array($first, $second);
Should instead be
if(!is_array($second)) {
$second = array_filter(array_map...... etcetc);
}
return in_array($first, $second);
Max_admin 13 Jul, 2019
True, bug fixed!

Thanks!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.