Skip to content

Commit 2cacf78

Browse files
committed
Fix: Remove false positive due to not checking object_filter changes
1 parent 7ccae70 commit 2cacf78

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

application/controllers/EventRuleController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function indexAction(): void
4848
$ruleId = $this->params->getRequired('id');
4949

5050
$eventRuleConfigValues = $this->fromDb((int) $ruleId);
51-
$filter = &$eventRuleConfigValues['object_filter']; // Assignment by reference to is used as search editor is a
51+
$filter = $eventRuleConfigValues['object_filter']; // Assignment by reference to is used as search editor is a
5252
// different form and the config must have the updated
5353
// object_filter as soon as the search editor is closed
5454

@@ -65,7 +65,8 @@ public function indexAction(): void
6565
Url::fromPath(
6666
'notifications/event-rule/search-editor',
6767
['id' => $ruleId, 'object_filter' => $filter]
68-
)
68+
),
69+
$filter
6970
))
7071
->populate($eventRuleConfigValues)
7172
->on(Form::ON_SUCCESS, function (EventRuleConfigForm $form) use ($ruleId, $eventRuleConfigValues) {

application/forms/EventRuleConfigForm.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,20 @@ class EventRuleConfigForm extends Form
5050
/** @var bool Whether the config has an escalation with no condition */
5151
protected $hasZeroConditionEscalation = false;
5252

53+
/** @var ?string */
54+
protected $objectFilter;
55+
5356
/**
5457
* Create a new EventRuleConfigForm
5558
*
5659
* @param array<string, mixed> $config
5760
* @param Url $searchEditorUrl
5861
*/
59-
public function __construct(array $config, Url $searchEditorUrl)
62+
public function __construct(array $config, Url $searchEditorUrl, ?string $objectFilter)
6063
{
6164
$this->config = $config;
6265
$this->searchEditorUrl = $searchEditorUrl;
66+
$this->objectFilter = $objectFilter;
6367
}
6468

6569
public function hasBeenSubmitted(): bool
@@ -179,7 +183,7 @@ protected function assemble(): void
179183
$this->getElement('zero-condition-escalation')->setValue($defaultEscalationPrefix);
180184
}
181185

182-
$configFilter = new EventRuleConfigFilter($this->searchEditorUrl, $this->config['object_filter']);
186+
$configFilter = new EventRuleConfigFilter($this->searchEditorUrl, $this->objectFilter);
183187
$this->registerElement($configFilter);
184188

185189
$addEscalationButton = new SubmitButtonElement(
@@ -463,7 +467,8 @@ public function updateRule(int $id, array $config): int
463467
{
464468
$db = Database::get();
465469
$db->beginTransaction();
466-
$db->update('rule', ['object_filter' => $config['object_filter'] ?? null], ['id = ?' => $id]);
470+
471+
$db->update('rule', ['object_filter' => $this->objectFilter], ['id = ?' => $id]);
467472

468473
if (! isset($config['rule_escalation'])) {
469474
$db->commitTransaction();

0 commit comments

Comments
 (0)