If Conditions - IN checks for string not array

Use IN and NOT IN conditions with arrays in ChronoForms.

Overview

The If Conditions action incorrectly processes arrays as strings, causing PHP warnings.
Ensure the condition checks if the second parameter is an array before processing it as a string.

Answered
ChronoForms v6
he 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 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.