[icinga-checkins] icinga.org: icingaweb2-module-director/master: IcingaCommandArgumentForm: store command, not args

git at icinga.org git at icinga.org
Mon Aug 1 12:47:10 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 52e412002fe16bd62f9eb388383b67e270f64493
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=52e412002fe16bd62f9eb388383b67e270f64493

Author: Thomas Gelf <thomas at gelf.net>
Date:   Mon Aug  1 10:45:47 2016 +0000

IcingaCommandArgumentForm: store command, not args

refs #11536

---

 application/forms/IcingaCommandArgumentForm.php |    2 +-
 library/Director/Objects/IcingaArguments.php    |   13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/application/forms/IcingaCommandArgumentForm.php b/application/forms/IcingaCommandArgumentForm.php
index 62b7534..f7b0503 100644
--- a/application/forms/IcingaCommandArgumentForm.php
+++ b/application/forms/IcingaCommandArgumentForm.php
@@ -116,7 +116,7 @@ class IcingaCommandArgumentForm extends DirectorObjectForm
                 $this->translate('The argument %s has successfully been stored'),
                 $object->argument_name
             );
-            $object->store($this->db);
+            $cmd->store($this->db);
         } else {
             $this->setHttpResponseCode(304);
             $msg = $this->translate('No action taken, object has not been modified');
diff --git a/library/Director/Objects/IcingaArguments.php b/library/Director/Objects/IcingaArguments.php
index 3743d0f..8f15800 100644
--- a/library/Director/Objects/IcingaArguments.php
+++ b/library/Director/Objects/IcingaArguments.php
@@ -82,9 +82,16 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
 
     public function set($key, $value)
     {
-        $argument = IcingaCommandArgument::create(
-            $this->mungeCommandArgument($key, $value)
-        )->set('command_id', $this->object->id);
+        if ($value instanceof IcingaCommandArgument) {
+            $argument = $value;
+        } else {
+            $argument = IcingaCommandArgument::create(
+                $this->mungeCommandArgument($key, $value)
+            );
+        }
+
+        $argument->set('command_id', $this->object->id);
+
         $key = $argument->argument_name;
         if (array_key_exists($key, $this->arguments)) {
             $this->arguments[$key]->replaceWith($argument);



More information about the icinga-checkins mailing list