From ac32896be8e285dfd2e1a003b5c4e7bdd0514ccd Mon Sep 17 00:00:00 2001 From: Kevin Pham Date: Mon, 16 Oct 2023 15:32:34 +1100 Subject: [PATCH] fix: set_variable step to only update when changed - reduces noise (some flows might attempt to update the same value over and over) - step being entered into will still display as expected. --- classes/local/step/set_variable_trait.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/classes/local/step/set_variable_trait.php b/classes/local/step/set_variable_trait.php index 8b50eff1..cd3eff67 100644 --- a/classes/local/step/set_variable_trait.php +++ b/classes/local/step/set_variable_trait.php @@ -74,9 +74,15 @@ public function execute($input = null) { * @param mixed $value */ public function run(var_root $varobject, string $field, $value) { + // Do nothing if the value has not changed. + $currentvalue = $varobject->get($field); + if ($currentvalue === $value) { + return; + } + // Set the value in the variable tree. $varobject->set($field, $value); - $this->log("Set '{field}' as '{value}'", ['field' => $field, 'value' => $value]); + $this->log->info("Set '{field}' as '{value}'", ['field' => $field, 'value' => $value]); // We do not persist the value if it is a dry run. if ($this->is_dry_run()) {