Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpunit/functional/RuleRightCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function testExportXML(array $rule_data, ?array $itemtype_data)
$xmlERuleCriteria = $xmlERule->addChild('rulecriteria');
$xmlERuleCriteria->criteria = $rule_data['criteria']['field'];
$xmlERuleCriteria->condition = $rule_data['criteria']['condition'];
$xmlERuleCriteria->pattern = $itemtype ? $itemtype->getID() : $rule_data['criteria']['value'];
$xmlERuleCriteria->pattern = $itemtype ? $itemtype->fields['name'] : $rule_data['criteria']['value'];
}
if (isset($rule_data['action'])) {
$xmlERuleCriteria = $xmlERule->addChild('ruleaction');
Expand Down
10 changes: 9 additions & 1 deletion src/RuleCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1075,12 +1075,20 @@ public static function getRulesXMLFile($items = [])

$available_criteria = $rule->getCriterias();
$crit = $criteria['criteria'];

foreach ($available_criteria as $key => $criterion_def) {
if (isset($criterion_def['id']) && $criterion_def['id'] == $crit) {
$crit = $key;
break;
}
}

if (self::isCriteraADropdown($available_criteria, $criteria['condition'], $crit)) {
$criteria['pattern'] = Dropdown::getDropdownName(
$available_criteria[$crit]['table'],
$criteria['pattern'],
false,
true,
false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of the customer, isn't this change enough?
The foreach before doesn't seem necessary to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rom1-B The code was looking for criteria by their ID (mail_server), but they’re indexed by their key (MAIL_SERVER) in the available criteria array. As a result, isCriteriaADropdown() always returned false, and getDropdownName() was never called.

The loop to map IDs to keys, and now it works: the XML correctly contains the names instead of the IDs.

Could you ask for customer validation?

false,
''
);
Expand Down