Skip to content

Commit

Permalink
Workflow backup: Do not save attributes when they are null
Browse files Browse the repository at this point in the history
  • Loading branch information
justusdieckmann committed Apr 27, 2023
1 parent 1c048dc commit 9f38377
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions classes/local/backup/backup_lifecycle_workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ public function send_temp_file() {
*/
private function write_workflow() {
foreach (get_object_vars($this->workflow) as $prop => $value) {
$this->writer->writeAttribute($prop, $value);
if (!is_null($value)) {
$this->writer->writeAttribute($prop, $value);
}
}
}

Expand All @@ -118,13 +120,17 @@ private function write_triggers() {
foreach ($this->trigger as $trigger) {
$this->writer->startElement("trigger");
foreach (get_object_vars($trigger) as $prop => $value) {
$this->writer->writeAttribute($prop, $value);
if (!is_null($value)) {
$this->writer->writeAttribute($prop, $value);
}
}
$settings = settings_manager::get_settings($trigger->id, settings_type::TRIGGER);
foreach ($settings as $name => $value) {
$this->writer->startElement("setting");
$this->writer->writeAttribute('name', $name);
$this->writer->writeAttribute('value', $value);
if (!is_null($value)) {
$this->writer->writeAttribute('value', $value);
}
$this->writer->endElement();
}
$this->writer->endElement();
Expand All @@ -139,13 +145,17 @@ private function write_steps() {
foreach ($this->steps as $step) {
$this->writer->startElement("step");
foreach (get_object_vars($step) as $prop => $value) {
$this->writer->writeAttribute($prop, $value);
if (!is_null($value)) {
$this->writer->writeAttribute($prop, $value);
}
}
$settings = settings_manager::get_settings($step->id, settings_type::STEP);
foreach ($settings as $name => $value) {
$this->writer->startElement("setting");
$this->writer->writeAttribute('name', $name);
$this->writer->writeAttribute('value', $value);
if (!is_null($value)) {
$this->writer->writeAttribute('value', $value);
}
$this->writer->endElement();
}
$this->writer->endElement();
Expand Down

0 comments on commit 9f38377

Please sign in to comment.