Skip to content

Commit

Permalink
Fix import rule (fata error) when the criteria or action is a dropdow…
Browse files Browse the repository at this point in the history
…n and the id has been deleted
  • Loading branch information
ddurieux committed Feb 20, 2024
1 parent 191adc9 commit a3b5770
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion inc/rulecollection.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ static function exportRulesToXML($items = []) {
$available_criteria = $rule->getCriterias();
$crit = $criteria['criteria'];
if (self::isCriteraADropdown($available_criteria, $criteria['condition'], $crit)) {
$criteria['pattern']
$criteria['pattern']
= Html::clean(Dropdown::getDropdownName($available_criteria[$crit]['table'],
$criteria['pattern']));
}
Expand Down Expand Up @@ -1080,6 +1080,11 @@ static function previewImportRules() {
if (self::isCriteraADropdown($available_criteria,
$criteria['condition'], $crit)) {
//escape pattern
if (is_array($criteria['pattern'])
&& empty($criteria['pattern'])) {
continue;
}

$criteria['pattern'] = $DB->escape(Html::entity_decode_deep($criteria['pattern']));
$itemtype = getItemTypeForTable($available_criteria[$crit]['table']);
$item = new $itemtype();
Expand Down Expand Up @@ -1121,6 +1126,10 @@ static function previewImportRules() {
}

//escape value
if (is_array($action['value'])
&& empty($action['value'])) {
continue;
}
$action['value'] = $DB->escape(Html::entity_decode_deep($action['value']));
$itemtype = getItemTypeForTable($available_actions[$act]['table']);
$item = new $itemtype();
Expand Down

0 comments on commit a3b5770

Please sign in to comment.