2
0
forked from Wavyzz/dolibarr

FIX in dev for #33324

This commit is contained in:
ldestailleur
2025-03-04 20:50:54 +01:00
parent 14bc9d3ab0
commit 04b0b3d855
2 changed files with 27 additions and 5 deletions

View File

@@ -11959,15 +11959,20 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
$value = preg_replace('/\s*\|\s*/', '|', $value);
// Split criteria on ' ' but not if we are inside quotes
$crits = dolExplodeKeepIfQuotes($value);
// Split criteria on ' ' but not if we are inside quotes.
// For mode 3, the split is done later on the , only and not on the ' '.
if ($mode != -3 && $mode != 3) {
$crits = dolExplodeKeepIfQuotes($value);
} else {
$crits = array($value);
}
$res = '';
if (!is_array($fields)) {
$fields = array($fields);
}
$i1 = 0; // count the nb of and criteria added (all fields / criteria)
$i1 = 0; // count the nb of "and" criteria added (all fields / criteria)
foreach ($crits as $crit) { // Loop on each AND criteria
$crit = trim($crit);
$i2 = 0; // count the nb of valid criteria added for this this first criteria
@@ -12022,7 +12027,8 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
$listofcodes .= "'".$db->escape($val)."'";
}
}
$newres .= ($i2 > 0 ? ' OR ' : '').$db->sanitize($field)." ".($mode == -3 ? 'NOT ' : '')."IN (".$db->sanitize($listofcodes, 1).")";
$newres .= ($i2 > 0 ? ' OR ' : '').$db->sanitize($field)." ".($mode == -3 ? 'NOT ' : '')."IN (".$db->sanitize($listofcodes, 1, 0, 1).")";
$i2++; // a criteria for 1 more field was added to string
}
if ($mode == -3) {