Skip to content

Commit

Permalink
Merge pull request #844 from catalyst/qol-reduce-spam
Browse files Browse the repository at this point in the history
fix: set_variable step to only update when changed
  • Loading branch information
Peterburnett authored Oct 17, 2023
2 parents 0130c68 + ac32896 commit cb138aa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion classes/local/step/set_variable_trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit cb138aa

Please sign in to comment.