From 558c1a1dbda2865d26f102103363dc7c0d1a356d Mon Sep 17 00:00:00 2001 From: "m.crews" Date: Wed, 19 Apr 2023 12:44:45 +0100 Subject: [PATCH] Fix #9601 - Fix bug where report conditions parenthesis pairs would not save correctly. --- modules/AOR_Conditions/AOR_Condition.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/AOR_Conditions/AOR_Condition.php b/modules/AOR_Conditions/AOR_Condition.php index 1ec4e2345aa..1331aca86c1 100755 --- a/modules/AOR_Conditions/AOR_Condition.php +++ b/modules/AOR_Conditions/AOR_Condition.php @@ -122,11 +122,11 @@ public function save_lines($post_data, $parent, $key = '') } } } - if ($field_name == 'parenthesis' && $post_data[$key . $field_name][$i] == 'END') { - if (!isset($lastParenthesisStartConditionId)) { + if ($field_name === 'parenthesis' && $post_data[$key . $field_name][$i] !== 'START') { + if (!isset($lastParenthesisStartConditionIds)) { throw new Exception('a closure parenthesis has no starter pair'); } - $condition->parenthesis = $lastParenthesisStartConditionId; + $condition->parenthesis = array_pop($lastParenthesisStartConditionIds); } else { $condition->$field_name = $post_data[$key . $field_name][$i]; } @@ -149,8 +149,8 @@ public function save_lines($post_data, $parent, $key = '') } $condition->aor_report_id = $parent->id; $conditionId = $condition->save(); - if ($condition->parenthesis == 'START') { - $lastParenthesisStartConditionId = $conditionId; + if ($condition->parenthesis === 'START') { + $lastParenthesisStartConditionIds[] = $conditionId; } } }