Skip to content

Commit

Permalink
Don't pass an array to ObjectsCommand::setObjects()
Browse files Browse the repository at this point in the history
fixes #832
  • Loading branch information
nilmerg committed Aug 10, 2023
1 parent 17adfc2 commit 987a0a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion application/controllers/HostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Controllers;

use ArrayIterator;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Icingadb\Command\Object\GetObjectCommand;
use Icinga\Module\Icingadb\Command\Transport\CommandTransport;
Expand Down Expand Up @@ -86,7 +87,11 @@ public function indexAction()
public function sourceAction()
{
$this->assertPermission('icingadb/object/show-source');
$apiResult = (new CommandTransport())->send((new GetObjectCommand())->setObjects([$this->host]));

$apiResult = (new CommandTransport())->send(
(new GetObjectCommand())
->setObjects(new ArrayIterator([$this->host]))
);

if ($this->host->state->is_overdue) {
$this->controls->addAttributes(['class' => 'overdue']);
Expand Down
7 changes: 6 additions & 1 deletion application/controllers/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Controllers;

use ArrayIterator;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Icingadb\Command\Object\GetObjectCommand;
use Icinga\Module\Icingadb\Command\Transport\CommandTransport;
Expand Down Expand Up @@ -91,7 +92,11 @@ public function indexAction()
public function sourceAction()
{
$this->assertPermission('icingadb/object/show-source');
$apiResult = (new CommandTransport())->send((new GetObjectCommand())->setObjects([$this->service]));

$apiResult = (new CommandTransport())->send(
(new GetObjectCommand())
->setObjects(new ArrayIterator([$this->service]))
);

if ($this->service->state->is_overdue) {
$this->controls->addAttributes(['class' => 'overdue']);
Expand Down
3 changes: 2 additions & 1 deletion library/Icingadb/Command/Object/ObjectsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Command\Object;

use ArrayIterator;
use Icinga\Module\Icingadb\Command\IcingaCommand;
use ipl\Orm\Model;
use Traversable;
Expand Down Expand Up @@ -45,7 +46,7 @@ public function setObjects(Traversable $objects): self
*/
public function setObject(Model $object): self
{
return $this->setObjects([$object]);
return $this->setObjects(new ArrayIterator([$object]));
}

/**
Expand Down

0 comments on commit 987a0a3

Please sign in to comment.