Fix `PSR-12` violations
This commit is contained in:
parent
48ad72f9c2
commit
00985429c5
|
@ -90,7 +90,7 @@ class CommandController extends ObjectController
|
|||
$o = $this->object;
|
||||
$this->tabs()->activate('arguments');
|
||||
$this->addTitle($this->translate('Command arguments: %s'), $o->getObjectName());
|
||||
$form = (new IcingaCommandArgumentForm)
|
||||
$form = (new IcingaCommandArgumentForm())
|
||||
->setBranch($this->getBranch())
|
||||
->setCommandObject($o);
|
||||
if ($argument = $p->shift('argument')) {
|
||||
|
|
|
@ -503,7 +503,8 @@ class ConfigController extends ActionController
|
|||
{
|
||||
$tabs = $this->tabs();
|
||||
|
||||
if ($this->hasPermission(Permission::DEPLOY)
|
||||
if (
|
||||
$this->hasPermission(Permission::DEPLOY)
|
||||
&& $deploymentId = $this->params->get('deployment_id')
|
||||
) {
|
||||
$tabs->add('deployment', [
|
||||
|
|
|
@ -36,7 +36,8 @@ class HostController extends ObjectController
|
|||
$host = $this->getHostObject();
|
||||
$auth = $this->Auth();
|
||||
$backend = $this->backend();
|
||||
if ($this->isServiceAction()
|
||||
if (
|
||||
$this->isServiceAction()
|
||||
&& $backend->canModifyService($host->getObjectName(), $this->getParam('service'))
|
||||
) {
|
||||
return;
|
||||
|
@ -147,7 +148,8 @@ class HostController extends ObjectController
|
|||
|
||||
if ($info && $auth->hasPermission(Permission::HOSTS)) {
|
||||
$redirectUrl = $info->getUrl();
|
||||
} elseif ($info
|
||||
} elseif (
|
||||
$info
|
||||
&& (($backend instanceof Monitoring && $auth->hasPermission(Permission::MONITORING_HOSTS))
|
||||
|| ($backend instanceof IcingadbBackend && $auth->hasPermission(Permission::ICINGADB_HOSTS))
|
||||
)
|
||||
|
@ -593,7 +595,8 @@ class HostController extends ObjectController
|
|||
$host = $this->object;
|
||||
try {
|
||||
$backend = $this->backend();
|
||||
if ($host instanceof IcingaHost
|
||||
if (
|
||||
$host instanceof IcingaHost
|
||||
&& $host->isObject()
|
||||
&& $backend->hasHost($host->getObjectName())
|
||||
) {
|
||||
|
|
|
@ -29,7 +29,8 @@ class ServiceController extends ObjectController
|
|||
|
||||
protected function checkDirectorPermissions()
|
||||
{
|
||||
if ($this->host
|
||||
if (
|
||||
$this->host
|
||||
&& $this->object
|
||||
&& $this->backend()->canModifyService($this->host->getObjectName(), $this->object->getObjectName())
|
||||
) {
|
||||
|
@ -190,7 +191,8 @@ class ServiceController extends ObjectController
|
|||
}
|
||||
|
||||
try {
|
||||
if ($object->isTemplate()
|
||||
if (
|
||||
$object->isTemplate()
|
||||
&& $object->getResolvedProperty('check_command_id')
|
||||
) {
|
||||
$this->view->actionLinks .= ' ' . $this->view->qlink(
|
||||
|
|
|
@ -65,7 +65,8 @@ class BasketUploadForm extends DirectorObjectForm
|
|||
throw new IcingaException('Got no file');
|
||||
}
|
||||
|
||||
if (! isset($_FILES['uploaded_file']['tmp_name'])
|
||||
if (
|
||||
! isset($_FILES['uploaded_file']['tmp_name'])
|
||||
|| ! is_uploaded_file($_FILES['uploaded_file']['tmp_name'])
|
||||
) {
|
||||
$this->addError('Got no uploaded file');
|
||||
|
|
|
@ -51,11 +51,13 @@ trait DeployFormsBug7530
|
|||
];
|
||||
|
||||
foreach ($objectTypes as $objectType) {
|
||||
if ((int) $db->fetchOne(
|
||||
if (
|
||||
(int) $db->fetchOne(
|
||||
$db->select()
|
||||
->from($objectType, 'COUNT(*)')
|
||||
->where('zone_id IN (?)', $zoneIds)
|
||||
) > 0) {
|
||||
) > 0
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +72,8 @@ trait DeployFormsBug7530
|
|||
$version = $this->api->getVersion();
|
||||
if ($version === null) {
|
||||
throw new \RuntimeException($this->translate('Unable to detect your Icinga 2 Core version'));
|
||||
} elseif (\version_compare($version, '2.11.0', '>=')
|
||||
} elseif (
|
||||
\version_compare($version, '2.11.0', '>=')
|
||||
&& \version_compare($version, '2.12.0', '<')
|
||||
) {
|
||||
return true;
|
||||
|
|
|
@ -54,7 +54,8 @@ class IcingaCloneObjectForm extends DirectorForm
|
|||
));
|
||||
}
|
||||
|
||||
if (!$branchOnly && ($this->object instanceof IcingaHost
|
||||
if (
|
||||
!$branchOnly && ($this->object instanceof IcingaHost
|
||||
|| $this->object instanceof IcingaServiceSet)
|
||||
) {
|
||||
$this->addBoolean('clone_services', [
|
||||
|
@ -97,7 +98,8 @@ class IcingaCloneObjectForm extends DirectorForm
|
|||
}
|
||||
}
|
||||
|
||||
if (($this->object->isTemplate() || $this->object instanceof IcingaCommand)
|
||||
if (
|
||||
($this->object->isTemplate() || $this->object instanceof IcingaCommand)
|
||||
&& $this->object->supportsFields()
|
||||
) {
|
||||
$this->addBoolean('clone_fields', [
|
||||
|
|
|
@ -209,7 +209,8 @@ class IcingaHostForm extends DirectorObjectForm
|
|||
*/
|
||||
protected function addGroupsElement()
|
||||
{
|
||||
if ($this->hasHostGroupRestriction()
|
||||
if (
|
||||
$this->hasHostGroupRestriction()
|
||||
&& ! $this->getAuth()->hasPermission(Permission::GROUPS_FOR_RESTRICTED_HOSTS)
|
||||
) {
|
||||
return $this;
|
||||
|
|
|
@ -282,10 +282,12 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||
$db = $this->db->getDbAdapter();
|
||||
$host->unsetOverriddenServiceVars($this->object->getObjectName())->store();
|
||||
|
||||
if ($db->insert('icinga_host_service_blacklist', [
|
||||
if (
|
||||
$db->insert('icinga_host_service_blacklist', [
|
||||
'host_id' => $host->get('id'),
|
||||
'service_id' => $service->get('id')
|
||||
])) {
|
||||
])
|
||||
) {
|
||||
$msg = sprintf(
|
||||
$this->translate('%s has been deactivated on %s'),
|
||||
$service->getObjectName(),
|
||||
|
|
|
@ -41,8 +41,10 @@ class KickstartForm extends DirectorForm
|
|||
$this->addResourceConfigElements();
|
||||
$this->addResourceDisplayGroup();
|
||||
|
||||
if (!$this->config()->get('db', 'resource')
|
||||
|| ($this->config()->get('db', 'resource') !== $this->getResourceName())) {
|
||||
if (
|
||||
!$this->config()->get('db', 'resource')
|
||||
|| ($this->config()->get('db', 'resource') !== $this->getResourceName())
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -353,8 +355,10 @@ class KickstartForm extends DirectorForm
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->getSubmitLabel() === $this->createDbLabel
|
||||
|| $this->getSubmitLabel() === $this->migrateDbLabel) {
|
||||
if (
|
||||
$this->getSubmitLabel() === $this->createDbLabel
|
||||
|| $this->getSubmitLabel() === $this->migrateDbLabel
|
||||
) {
|
||||
$this->migrations()->applyPendingMigrations();
|
||||
parent::onSuccess();
|
||||
}
|
||||
|
@ -448,7 +452,8 @@ class KickstartForm extends DirectorForm
|
|||
{
|
||||
if ($resourceName = $this->getResourceName()) {
|
||||
$resourceConfig = ResourceFactory::getResourceConfig($resourceName);
|
||||
if (!isset($resourceConfig->charset)
|
||||
if (
|
||||
!isset($resourceConfig->charset)
|
||||
|| !in_array($resourceConfig->charset, array('utf8', 'utf8mb4', 'UTF8', 'UTF-8'))
|
||||
) {
|
||||
if ($resource = $this->getElement('resource')) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
// Avoid complaints about missing namespace and invalid class name
|
||||
// @codingStandardsIgnoreStart
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ class CoreApi implements DeploymentApiInterface
|
|||
{
|
||||
$version = $this->getVersion();
|
||||
|
||||
if ($version === null ||
|
||||
if (
|
||||
$version === null ||
|
||||
((version_compare($version, '2.8.2', '>=') && version_compare($version, '2.10.2', '<')))
|
||||
) {
|
||||
$this->client->disconnect();
|
||||
|
@ -681,7 +682,8 @@ constants
|
|||
continue;
|
||||
}
|
||||
|
||||
if (in_array('startup.log', $availableFiles)
|
||||
if (
|
||||
in_array('startup.log', $availableFiles)
|
||||
&& in_array('status', $availableFiles)
|
||||
) {
|
||||
if ($this->getStagedFile($stage, 'status') === '0') {
|
||||
|
|
|
@ -55,7 +55,8 @@ class LegacyDeploymentApi implements DeploymentApiInterface
|
|||
continue;
|
||||
}
|
||||
|
||||
if (in_array('startup.log', $availableFiles)
|
||||
if (
|
||||
in_array('startup.log', $availableFiles)
|
||||
&& in_array('status', $availableFiles)
|
||||
) {
|
||||
$status = $this->getStagedFile($stage, 'status');
|
||||
|
@ -91,7 +92,8 @@ class LegacyDeploymentApi implements DeploymentApiInterface
|
|||
// try to expire old deployments
|
||||
foreach ($uncollected as $name => $deployment) {
|
||||
/** @var DirectorDeploymentLog $deployment */
|
||||
if ($deployment->get('dump_succeeded') === 'n'
|
||||
if (
|
||||
$deployment->get('dump_succeeded') === 'n'
|
||||
|| $deployment->get('startup_succeeded') === null
|
||||
) {
|
||||
$start_time = strtotime($deployment->start_time);
|
||||
|
@ -106,7 +108,8 @@ class LegacyDeploymentApi implements DeploymentApiInterface
|
|||
}
|
||||
|
||||
foreach ($this->listPackageStages($packageName) as $stage) {
|
||||
if (array_key_exists($stage, $uncollected)
|
||||
if (
|
||||
array_key_exists($stage, $uncollected)
|
||||
&& $uncollected[$stage]->get('startup_succeeded') === null
|
||||
) {
|
||||
continue;
|
||||
|
@ -177,7 +180,8 @@ class LegacyDeploymentApi implements DeploymentApiInterface
|
|||
while ($file = readdir($dh)) {
|
||||
if ($file === '.' || $file === '..') {
|
||||
continue;
|
||||
} elseif (is_dir($this->deploymentPath . DIRECTORY_SEPARATOR . $file)
|
||||
} elseif (
|
||||
is_dir($this->deploymentPath . DIRECTORY_SEPARATOR . $file)
|
||||
&& substr($file, 0, 9) === 'director-'
|
||||
) {
|
||||
$stages[] = $file;
|
||||
|
|
|
@ -17,13 +17,13 @@ class RestApiResponse
|
|||
|
||||
public static function fromJsonResult($json)
|
||||
{
|
||||
$response = new static;
|
||||
$response = new static();
|
||||
return $response->parseJsonResult($json);
|
||||
}
|
||||
|
||||
public static function fromErrorMessage($error)
|
||||
{
|
||||
$response = new static;
|
||||
$response = new static();
|
||||
$response->errorMessage = $error;
|
||||
|
||||
return $response;
|
||||
|
|
|
@ -183,7 +183,7 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
|
|||
)
|
||||
)->where(sprintf('v.%s = ?', $object->getVarsIdColumn()), $object->get('id'));
|
||||
|
||||
$vars = new CustomVariables;
|
||||
$vars = new CustomVariables();
|
||||
foreach ($db->fetchAll($query) as $row) {
|
||||
$vars->vars[$row->varname] = CustomVariable::fromDbRow($row);
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
|
|||
|
||||
public static function forStoredRows($rows)
|
||||
{
|
||||
$vars = new CustomVariables;
|
||||
$vars = new CustomVariables();
|
||||
foreach ($rows as $row) {
|
||||
$vars->vars[$row->varname] = CustomVariable::fromDbRow($row);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use React\EventLoop\LoopInterface;
|
|||
use React\Promise\Deferred;
|
||||
use RuntimeException;
|
||||
use SplObjectStorage;
|
||||
|
||||
use function React\Promise\reject;
|
||||
use function React\Promise\resolve;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use Exception;
|
|||
use Icinga\Module\Director\Db;
|
||||
use Icinga\Module\Director\Objects\DirectorDeploymentLog;
|
||||
use React\EventLoop\LoopInterface;
|
||||
|
||||
use function React\Promise\resolve;
|
||||
|
||||
class DeploymentChecker implements DbBasedComponent
|
||||
|
|
|
@ -10,6 +10,7 @@ use Icinga\Module\Director\Objects\DirectorJob;
|
|||
use React\ChildProcess\Process;
|
||||
use React\EventLoop\LoopInterface;
|
||||
use React\Promise\Promise;
|
||||
|
||||
use function React\Promise\resolve;
|
||||
|
||||
class JobRunner implements DbBasedComponent
|
||||
|
@ -139,9 +140,11 @@ class JobRunner implements DbBasedComponent
|
|||
{
|
||||
$db = $this->db->getDbAdapter();
|
||||
|
||||
foreach ($db->fetchCol(
|
||||
foreach (
|
||||
$db->fetchCol(
|
||||
$db->select()->from('director_job', 'id')->where('disabled = ?', 'n')
|
||||
) as $id) {
|
||||
) as $id
|
||||
) {
|
||||
$this->scheduledIds[] = (int) $id;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Daemon;
|
|||
|
||||
use Exception;
|
||||
use Icinga\Module\Director\Db;
|
||||
|
||||
use function React\Promise\resolve;
|
||||
|
||||
class LogProxy implements DbBasedComponent
|
||||
|
|
|
@ -8,6 +8,7 @@ use ipl\Stdlib\EventEmitter;
|
|||
use React\ChildProcess\Process;
|
||||
use React\EventLoop\LoopInterface;
|
||||
use React\Promise\Deferred;
|
||||
|
||||
use function React\Promise\resolve;
|
||||
|
||||
class ProcessList
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Director\Data;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
use function array_diff;
|
||||
use function array_key_exists;
|
||||
use function implode;
|
||||
|
|
|
@ -103,7 +103,8 @@ abstract class DbObject
|
|||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
if ($this->table === null
|
||||
if (
|
||||
$this->table === null
|
||||
|| $this->keyName === null
|
||||
|| $this->defaultProperties === null
|
||||
) {
|
||||
|
@ -366,7 +367,8 @@ abstract class DbObject
|
|||
));
|
||||
}
|
||||
|
||||
if ((is_numeric($value) || is_string($value))
|
||||
if (
|
||||
(is_numeric($value) || is_string($value))
|
||||
&& (string) $value === (string) $this->get($key)
|
||||
) {
|
||||
return $this;
|
||||
|
@ -385,7 +387,8 @@ abstract class DbObject
|
|||
return $this;
|
||||
}
|
||||
if ($key === 'id' || substr($key, -3) === '_id') {
|
||||
if ($value !== null
|
||||
if (
|
||||
$value !== null
|
||||
&& $this->properties[$key] !== null
|
||||
&& (int) $value === (int) $this->properties[$key]
|
||||
) {
|
||||
|
@ -1206,7 +1209,8 @@ abstract class DbObject
|
|||
{
|
||||
$class = get_called_class();
|
||||
if (static::hasPrefetched($key)) {
|
||||
if (is_string($key)
|
||||
if (
|
||||
is_string($key)
|
||||
&& array_key_exists($class, self::$prefetchedNames)
|
||||
&& array_key_exists($key, self::$prefetchedNames[$class])
|
||||
) {
|
||||
|
@ -1239,7 +1243,8 @@ abstract class DbObject
|
|||
}
|
||||
|
||||
if (array_key_exists($class, self::$prefetched)) {
|
||||
if (is_string($key)
|
||||
if (
|
||||
is_string($key)
|
||||
&& array_key_exists($class, self::$prefetchedNames)
|
||||
&& array_key_exists($key, self::$prefetchedNames[$class])
|
||||
) {
|
||||
|
@ -1283,7 +1288,7 @@ abstract class DbObject
|
|||
return $prefetched;
|
||||
}
|
||||
|
||||
$obj = new static;
|
||||
$obj = new static();
|
||||
if (self::$dbObjectStore !== null && $obj->hasUuidColumn()) {
|
||||
$table = $obj->getTableName();
|
||||
assert($connection instanceof Db);
|
||||
|
@ -1311,7 +1316,7 @@ abstract class DbObject
|
|||
return $prefetched;
|
||||
}
|
||||
/** @var DbObject $obj */
|
||||
$obj = new static;
|
||||
$obj = new static();
|
||||
|
||||
if (self::$dbObjectStore !== null && $obj->hasUuidColumn()) {
|
||||
$table = $obj->getTableName();
|
||||
|
@ -1373,7 +1378,7 @@ abstract class DbObject
|
|||
$db = $connection->getDbAdapter();
|
||||
|
||||
if ($query === null) {
|
||||
$dummy = new static;
|
||||
$dummy = new static();
|
||||
$select = $db->select()->from($dummy->table);
|
||||
} else {
|
||||
$select = $query;
|
||||
|
@ -1382,7 +1387,7 @@ abstract class DbObject
|
|||
|
||||
foreach ($rows as $row) {
|
||||
/** @var DbObject $obj */
|
||||
$obj = new static;
|
||||
$obj = new static();
|
||||
$obj->setConnection($connection)->setDbProperties($row);
|
||||
if ($keyColumn === null) {
|
||||
$objects[] = $obj;
|
||||
|
@ -1452,7 +1457,7 @@ abstract class DbObject
|
|||
}
|
||||
|
||||
/** @var DbObject $obj */
|
||||
$obj = new static;
|
||||
$obj = new static();
|
||||
if (self::$dbObjectStore !== null && $obj->hasUuidColumn()) {
|
||||
$table = $obj->getTableName();
|
||||
assert($connection instanceof Db);
|
||||
|
@ -1471,7 +1476,7 @@ abstract class DbObject
|
|||
public static function uniqueIdExists(UuidInterface $uuid, DbConnection $connection)
|
||||
{
|
||||
$db = $connection->getDbAdapter();
|
||||
$obj = new static;
|
||||
$obj = new static();
|
||||
$column = $obj->getUuidColumn();
|
||||
$query = $db->select()
|
||||
->from($obj->getTableName(), $column)
|
||||
|
@ -1490,7 +1495,7 @@ abstract class DbObject
|
|||
|
||||
throw new NotFoundError(sprintf(
|
||||
'No %s with UUID=%s has been found',
|
||||
(new static)->getTableName(),
|
||||
(new static())->getTableName(),
|
||||
$uuid->toString()
|
||||
));
|
||||
}
|
||||
|
@ -1498,7 +1503,7 @@ abstract class DbObject
|
|||
public static function loadWithUniqueId(UuidInterface $uuid, DbConnection $connection): ?DbObject
|
||||
{
|
||||
$db = $connection->getDbAdapter();
|
||||
$obj = new static;
|
||||
$obj = new static();
|
||||
|
||||
if (self::$dbObjectStore !== null && $obj->hasUuidColumn()) {
|
||||
$table = $obj->getTableName();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Director\Data;
|
||||
|
||||
use Icinga\Module\Director\Exception\JsonEncodeException;
|
||||
|
||||
use function json_decode;
|
||||
use function json_encode;
|
||||
use function json_last_error;
|
||||
|
|
|
@ -120,7 +120,8 @@ class ObjectImporter
|
|||
*/
|
||||
protected function loadExistingObject(string $implementation, stdClass $plain): ?DbObject
|
||||
{
|
||||
if (isset($plain->uuid)
|
||||
if (
|
||||
isset($plain->uuid)
|
||||
&& $instance = $implementation::loadWithUniqueId(Uuid::fromString($plain->uuid), $this->db)
|
||||
) {
|
||||
return $instance;
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Icinga\Module\Director\Data;
|
|||
use InvalidArgumentException;
|
||||
use JsonSerializable;
|
||||
use stdClass;
|
||||
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function is_array;
|
||||
|
@ -21,7 +22,7 @@ class SerializableValue implements Serializable
|
|||
*/
|
||||
public static function fromSerialization($value)
|
||||
{
|
||||
$self = new static;
|
||||
$self = new static();
|
||||
static::assertSerializableValue($value);
|
||||
$self->value = $value;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class DataTypeBoolean extends DataTypeHook
|
|||
$vhClass = 'Zend_Form_Decorator_ViewHelper';
|
||||
$decorators = $element->getDecorators();
|
||||
if (array_key_exists($vhClass, $decorators)) {
|
||||
$decorators[$vhClass] = new ViewHelperRaw;
|
||||
$decorators[$vhClass] = new ViewHelperRaw();
|
||||
$element->setDecorators($decorators);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,10 +76,12 @@ class DataTypeDatalist extends DataTypeHook
|
|||
*/
|
||||
protected function createEntryIfNotExists(Db $db, $listId, $entry)
|
||||
{
|
||||
if (! DirectorDatalistEntry::exists([
|
||||
if (
|
||||
! DirectorDatalistEntry::exists([
|
||||
'list_id' => $listId,
|
||||
'entry_name' => $entry,
|
||||
], $db)) {
|
||||
], $db)
|
||||
) {
|
||||
DirectorDatalistEntry::create([
|
||||
'list_id' => $listId,
|
||||
'entry_name' => $entry,
|
||||
|
|
|
@ -12,7 +12,7 @@ class DataTypeNumber extends DataTypeHook
|
|||
{
|
||||
$element = $form->createElement('text', $name)
|
||||
->addValidator('int')
|
||||
->addFilter(new FilterInt);
|
||||
->addFilter(new FilterInt());
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class Branch
|
|||
|
||||
public static function fromDbRow(stdClass $row)
|
||||
{
|
||||
$self = new static;
|
||||
$self = new static();
|
||||
if (is_resource($row->uuid)) {
|
||||
$row->uuid = stream_get_contents($row->uuid);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class Branch
|
|||
return $hook->getBranchForRequest($request, $store, $auth);
|
||||
}
|
||||
|
||||
return new Branch;
|
||||
return new Branch();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Director\Db\Branch;
|
||||
|
||||
use Icinga\Module\Director\Data\Json;
|
||||
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,7 @@ use Icinga\Module\Director\Objects\IcingaHost;
|
|||
use Icinga\Module\Director\Objects\IcingaServiceSet;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
use function is_int;
|
||||
use function is_resource;
|
||||
use function is_string;
|
||||
|
|
|
@ -8,6 +8,7 @@ use gipfl\ZfDb\Expr;
|
|||
use Zend_Db_Adapter_Abstract;
|
||||
use Zend_Db_Adapter_Pdo_Pgsql;
|
||||
use Zend_Db_Expr;
|
||||
|
||||
use function bin2hex;
|
||||
use function is_array;
|
||||
use function is_resource;
|
||||
|
|
|
@ -59,7 +59,8 @@ class IcingaObjectFilterHelper
|
|||
if ($branchuuid) {
|
||||
if ($inheritanceType === self::INHERIT_DIRECT) {
|
||||
return $query->where('imports LIKE \'%"' . $template->getObjectName() . '"%\'');
|
||||
} elseif ($inheritanceType === self::INHERIT_INDIRECT
|
||||
} elseif (
|
||||
$inheritanceType === self::INHERIT_INDIRECT
|
||||
|| $inheritanceType === self::INHERIT_DIRECT_OR_INDIRECT
|
||||
) {
|
||||
$tree = new TemplateTree($type, $template->getConnection());
|
||||
|
@ -90,7 +91,8 @@ class IcingaObjectFilterHelper
|
|||
|
||||
if ($inheritanceType === self::INHERIT_DIRECT) {
|
||||
$sub->where("$i.parent_{$type}_id = ?", $id);
|
||||
} elseif ($inheritanceType === self::INHERIT_INDIRECT
|
||||
} elseif (
|
||||
$inheritanceType === self::INHERIT_INDIRECT
|
||||
|| $inheritanceType === self::INHERIT_DIRECT_OR_INDIRECT
|
||||
) {
|
||||
$tree = new TemplateTree($type, $template->getConnection());
|
||||
|
|
|
@ -443,7 +443,8 @@ class BasketSnapshot extends DbObject
|
|||
foreach ($filter as $column => $value) {
|
||||
$select->where("$column = ?", $value);
|
||||
}
|
||||
} elseif (! $dummy->isGroup()
|
||||
} elseif (
|
||||
! $dummy->isGroup()
|
||||
// TODO: this is ugly.
|
||||
&& ! $dummy instanceof IcingaDependency
|
||||
&& ! $dummy instanceof IcingaTimePeriod
|
||||
|
|
|
@ -87,9 +87,11 @@ class BasketSnapshotFieldResolver
|
|||
|
||||
$db = $this->targetDb->getDbAdapter();
|
||||
|
||||
foreach ($db->fetchAll(
|
||||
foreach (
|
||||
$db->fetchAll(
|
||||
$db->select()->from($table)->where("$objectKey = ?", $objectId)
|
||||
) as $mapping) {
|
||||
) as $mapping
|
||||
) {
|
||||
$existingFields[(int) $mapping->datafield_id] = $mapping;
|
||||
}
|
||||
foreach ($object->fields as $field) {
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Icinga\Module\Director\DirectorObject\Automation;
|
|||
use Icinga\Module\Director\Core\Json;
|
||||
use ipl\Html\Error;
|
||||
use RuntimeException;
|
||||
|
||||
use function array_key_exists;
|
||||
use function is_array;
|
||||
use function is_object;
|
||||
|
|
|
@ -36,13 +36,15 @@ class ServiceFinder
|
|||
|
||||
public static function find(IcingaHost $host, $serviceName)
|
||||
{
|
||||
foreach ([
|
||||
foreach (
|
||||
[
|
||||
SingleServiceInfo::class,
|
||||
InheritedServiceInfo::class,
|
||||
ServiceSetServiceInfo::class,
|
||||
AppliedServiceInfo::class,
|
||||
AppliedServiceSetServiceInfo::class,
|
||||
] as $class) {
|
||||
] as $class
|
||||
) {
|
||||
/** @var ServiceInfo $class */
|
||||
if ($info = $class::find($host, $serviceName)) {
|
||||
return $info;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Icinga\Module\Director\Field;
|
||||
|
||||
use Icinga\Module\Director\Objects\DirectorDatafield;
|
||||
|
|
|
@ -63,7 +63,8 @@ class FormFieldSuggestion
|
|||
}
|
||||
}
|
||||
|
||||
if (($arg->set_if_format === 'string' || $arg->set_if_format === null)
|
||||
if (
|
||||
($arg->set_if_format === 'string' || $arg->set_if_format === null)
|
||||
&& $val = self::getMacroIfStringIsSingleMacro($arg->set_if)
|
||||
) {
|
||||
$this->addSuggestion($val, $arg->description, $this->booleans);
|
||||
|
|
|
@ -16,7 +16,8 @@ class FilterEnrichment
|
|||
}
|
||||
} elseif ($filter instanceof FilterChain) {
|
||||
foreach ($filter->filters() as $subFilter) {
|
||||
if ($subFilter instanceof FilterExpression
|
||||
if (
|
||||
$subFilter instanceof FilterExpression
|
||||
&& CidrExpression::isCidrFormat($subFilter->getExpression())
|
||||
) {
|
||||
$filter->replaceById($subFilter->getId(), CidrExpression::fromExpression($subFilter));
|
||||
|
|
|
@ -48,7 +48,7 @@ abstract class ImportSourceHook
|
|||
}
|
||||
|
||||
/** @var ImportSourceHook $obj */
|
||||
$obj = new $className;
|
||||
$obj = new $className();
|
||||
$obj->setSettings($settings);
|
||||
return $obj;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ abstract class ImportSourceHook
|
|||
);
|
||||
}
|
||||
/** @var ImportSourceHook $obj */
|
||||
$obj = new $source->provider_class;
|
||||
$obj = new $source->provider_class();
|
||||
$obj->setSettings($settings);
|
||||
|
||||
return $obj;
|
||||
|
|
|
@ -144,7 +144,8 @@ class AssignRenderer
|
|||
|
||||
if (is_string($rawExpression) && ctype_digit($rawExpression)) {
|
||||
// TODO: doing this for compat reasons, should work for all filters
|
||||
if ($filter instanceof FilterEqualOrGreaterThan
|
||||
if (
|
||||
$filter instanceof FilterEqualOrGreaterThan
|
||||
|| $filter instanceof FilterGreaterThan
|
||||
|| $filter instanceof FilterEqualOrLessThan
|
||||
|| $filter instanceof FilterLessThan
|
||||
|
|
|
@ -46,7 +46,7 @@ class ExtensibleSet
|
|||
|
||||
public static function forIcingaObject(IcingaObject $object, $propertyName)
|
||||
{
|
||||
$set = new static;
|
||||
$set = new static();
|
||||
$set->object = $object;
|
||||
$set->propertyName = $propertyName;
|
||||
|
||||
|
@ -164,7 +164,8 @@ class ExtensibleSet
|
|||
|
||||
return false;
|
||||
} else {
|
||||
if ($this->ownValues === null
|
||||
if (
|
||||
$this->ownValues === null
|
||||
&& empty($this->plusValues)
|
||||
&& empty($this->minusValues)
|
||||
) {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Director\IcingaConfig;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
use function ctype_digit;
|
||||
use function explode;
|
||||
use function floor;
|
||||
|
|
|
@ -411,11 +411,13 @@ class Sync
|
|||
|
||||
foreach ($objects as $object) {
|
||||
if ($object instanceof IcingaService) {
|
||||
if (strstr($destinationKeyPattern, '${host}')
|
||||
if (
|
||||
strstr($destinationKeyPattern, '${host}')
|
||||
&& $object->get('host_id') === null
|
||||
) {
|
||||
continue;
|
||||
} elseif (strstr($destinationKeyPattern, '${service_set}')
|
||||
} elseif (
|
||||
strstr($destinationKeyPattern, '${service_set}')
|
||||
&& $object->get('service_set_id') === null
|
||||
) {
|
||||
continue;
|
||||
|
@ -450,7 +452,8 @@ class Sync
|
|||
if ($ruleObjectType === 'service' || $ruleObjectType === 'serviceSet') {
|
||||
foreach ($this->syncProperties as $prop) {
|
||||
$configuredObjectType = $prop->get('source_expression');
|
||||
if ($prop->get('destination_field') === 'object_type'
|
||||
if (
|
||||
$prop->get('destination_field') === 'object_type'
|
||||
&& (
|
||||
$configuredObjectType === 'template'
|
||||
|| ($configuredObjectType === 'apply' && $ruleObjectType === 'serviceSet')
|
||||
|
@ -659,10 +662,12 @@ class Sync
|
|||
protected function getHostGroupMembershipResolver()
|
||||
{
|
||||
if ($this->hostGroupMembershipResolver === null) {
|
||||
if (in_array(
|
||||
if (
|
||||
in_array(
|
||||
$this->rule->get('object_type'),
|
||||
['host', 'hostgroup']
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
$this->hostGroupMembershipResolver = new HostGroupMembershipResolver(
|
||||
$this->db
|
||||
);
|
||||
|
@ -788,7 +793,8 @@ class Sync
|
|||
|
||||
switch ($policy) {
|
||||
case 'override':
|
||||
if ($object instanceof IcingaHost
|
||||
if (
|
||||
$object instanceof IcingaHost
|
||||
&& !in_array('api_key', $this->rule->getSyncProperties())
|
||||
) {
|
||||
$this->objects[$key]->replaceWith($object, ['api_key']);
|
||||
|
|
|
@ -47,7 +47,8 @@ class IcingadbBackend implements BackendInterface
|
|||
|
||||
public function canModifyHost(?string $hostName): bool
|
||||
{
|
||||
if ($hostName === null
|
||||
if (
|
||||
$hostName === null
|
||||
|| ! $this->getAuth()->hasPermission(Permission::ICINGADB_HOSTS)
|
||||
) {
|
||||
return false;
|
||||
|
@ -60,7 +61,8 @@ class IcingadbBackend implements BackendInterface
|
|||
|
||||
public function canModifyService(?string $hostName, ?string $serviceName): bool
|
||||
{
|
||||
if ($hostName === null
|
||||
if (
|
||||
$hostName === null
|
||||
|| $serviceName === null
|
||||
|| ! $this->getAuth()->hasPermission(Permission::ICINGADB_SERVICES)
|
||||
) {
|
||||
|
|
|
@ -207,11 +207,12 @@ class DirectorDatafield extends DbObjectWithSettings
|
|||
}
|
||||
|
||||
/** @var DataTypeHook $dataType */
|
||||
$dataType = new $className;
|
||||
$dataType = new $className();
|
||||
$dataType->setSettings($this->getSettings());
|
||||
$el = $dataType->getFormElement($name, $form);
|
||||
|
||||
if ($this->getSetting('icinga_type') !== 'command'
|
||||
if (
|
||||
$this->getSetting('icinga_type') !== 'command'
|
||||
&& $this->getSetting('is_required') === 'y'
|
||||
) {
|
||||
$el->setRequired(true);
|
||||
|
|
|
@ -70,7 +70,7 @@ class DirectorJob extends DbObjectWithSettings implements ExportInterface, Insta
|
|||
{
|
||||
if ($this->job === null) {
|
||||
$class = $this->get('job_class');
|
||||
$this->job = new $class;
|
||||
$this->job = new $class();
|
||||
$this->job->setDb($this->connection);
|
||||
$this->job->setDefinition($this);
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ class DirectorJob extends DbObjectWithSettings implements ExportInterface, Insta
|
|||
protected static function existsWithNameAndId($name, $id, Db $connection)
|
||||
{
|
||||
$db = $connection->getDbAdapter();
|
||||
$dummy = new static;
|
||||
$dummy = new static();
|
||||
$idCol = $dummy->autoincKeyName;
|
||||
$keyCol = $dummy->keyName;
|
||||
|
||||
|
|
|
@ -216,10 +216,12 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
|
|||
$this->set($arg, $val);
|
||||
}
|
||||
|
||||
foreach (array_diff(
|
||||
foreach (
|
||||
array_diff(
|
||||
array_keys($this->arguments),
|
||||
array_keys($arguments)
|
||||
) as $arg) {
|
||||
) as $arg
|
||||
) {
|
||||
if ($this->arguments[$arg]->hasBeenLoadedFromDb()) {
|
||||
$this->arguments[$arg]->markForRemoval();
|
||||
$this->modified = true;
|
||||
|
|
|
@ -222,8 +222,10 @@ class IcingaCommand extends IcingaObject implements ObjectWithArguments, ExportI
|
|||
|
||||
$inherited = $this->getInheritedProperties();
|
||||
|
||||
if ($this->get('is_string') === 'y' || ($this->get('is_string') === null
|
||||
&& property_exists($inherited, 'is_string') && $inherited->is_string === 'y')) {
|
||||
if (
|
||||
$this->get('is_string') === 'y' || ($this->get('is_string') === null
|
||||
&& property_exists($inherited, 'is_string') && $inherited->is_string === 'y')
|
||||
) {
|
||||
return c::renderKeyValue('command', $prefix . c::renderString($command));
|
||||
} else {
|
||||
$parts = preg_split('/\s+/', $command, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
|
|
@ -408,7 +408,8 @@ class IcingaDependency extends IcingaObject implements ExportInterface
|
|||
public function renderChild_service_id()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if ($this->hasBeenAssignedToServiceTemplate()
|
||||
if (
|
||||
$this->hasBeenAssignedToServiceTemplate()
|
||||
|| $this->hasBeenAssignedToHostTemplateService()
|
||||
|| $this->hasBeenAssignedToServiceApply()
|
||||
) {
|
||||
|
@ -467,7 +468,8 @@ class IcingaDependency extends IcingaObject implements ExportInterface
|
|||
|
||||
public function isApplyRule()
|
||||
{
|
||||
if ($this->hasBeenAssignedToHostTemplate()
|
||||
if (
|
||||
$this->hasBeenAssignedToHostTemplate()
|
||||
|| $this->hasBeenAssignedToServiceTemplate()
|
||||
|| $this->hasBeenAssignedToServiceApply()
|
||||
) {
|
||||
|
@ -612,7 +614,8 @@ class IcingaDependency extends IcingaObject implements ExportInterface
|
|||
$related = parent::getRelatedProperty($key);
|
||||
// handle special case for plain string parent service on Dependency
|
||||
// Apply rules
|
||||
if ($related === null
|
||||
if (
|
||||
$related === null
|
||||
&& $key === 'parent_service'
|
||||
&& (
|
||||
$this->get('parent_service_by_name')
|
||||
|
|
|
@ -614,7 +614,8 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
return true;
|
||||
}
|
||||
|
||||
if ($this instanceof ObjectWithArguments
|
||||
if (
|
||||
$this instanceof ObjectWithArguments
|
||||
&& $this->gotArguments()
|
||||
&& $this->arguments()->hasBeenModified()
|
||||
) {
|
||||
|
@ -758,8 +759,10 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
return $this;
|
||||
}
|
||||
|
||||
if ($this instanceof ObjectWithArguments
|
||||
&& substr($key, 0, 10) === 'arguments.') {
|
||||
if (
|
||||
$this instanceof ObjectWithArguments
|
||||
&& substr($key, 0, 10) === 'arguments.'
|
||||
) {
|
||||
$this->arguments()->set(substr($key, 10), $value);
|
||||
return $this;
|
||||
}
|
||||
|
@ -1764,7 +1767,8 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
|
||||
$deploymentMode = $config->getDeploymentMode();
|
||||
if ($deploymentMode === 'active-passive') {
|
||||
if ($this->getSingleResolvedProperty('zone_id')
|
||||
if (
|
||||
$this->getSingleResolvedProperty('zone_id')
|
||||
&& array_key_exists('enable_active_checks', $this->defaultProperties)
|
||||
) {
|
||||
$passive = clone($this);
|
||||
|
@ -2115,7 +2119,8 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
);
|
||||
}
|
||||
|
||||
if (substr($key, -3) === '_id'
|
||||
if (
|
||||
substr($key, -3) === '_id'
|
||||
&& $this->hasRelation($relKey = substr($key, 0, -3))
|
||||
) {
|
||||
return $this->renderRelationProperty($relKey, $value);
|
||||
|
@ -2173,7 +2178,8 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
);
|
||||
}
|
||||
|
||||
if (substr($key, -3) === '_id'
|
||||
if (
|
||||
substr($key, -3) === '_id'
|
||||
&& $this->hasRelation($relKey = substr($key, 0, -3))
|
||||
) {
|
||||
return $this->renderLegacyRelationProperty($relKey, $value);
|
||||
|
@ -2401,7 +2407,8 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
$str = '';
|
||||
|
||||
// Set notification settings for the object to suppress warnings
|
||||
if (array_key_exists('enable_notifications', $this->defaultProperties)
|
||||
if (
|
||||
array_key_exists('enable_notifications', $this->defaultProperties)
|
||||
&& $this->isTemplate()
|
||||
) {
|
||||
$str .= c1::renderKeyValue('notification_period', 'notification_none');
|
||||
|
@ -2411,7 +2418,8 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
|
||||
// force rendering of check_command when ARG1 is set
|
||||
if ($this->supportsCustomVars() && array_key_exists('check_command_id', $this->defaultProperties)) {
|
||||
if ($this->get('check_command') === null
|
||||
if (
|
||||
$this->get('check_command') === null
|
||||
&& $this->vars()->get('ARG1') !== null
|
||||
) {
|
||||
$command = $this->getResolvedRelated('check_command');
|
||||
|
@ -2701,7 +2709,8 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||
}
|
||||
}
|
||||
|
||||
if (PrefetchCache::shouldBeUsed()
|
||||
if (
|
||||
PrefetchCache::shouldBeUsed()
|
||||
&& $query === null
|
||||
&& $keyColumn === static::getKeyColumnName()
|
||||
) {
|
||||
|
|
|
@ -47,7 +47,8 @@ class IcingaScheduledDowntimeRange extends DbObject
|
|||
{
|
||||
$hBegin = $mBegin = $hEnd = $mEnd = null;
|
||||
if (sscanf($rangeString, '%2d:%2d-%2d:%2d', $hBegin, $mBegin, $hEnd, $mEnd) === 4) {
|
||||
if ($this->timeFromHourMin($hBegin, $mBegin, $now) <= $now
|
||||
if (
|
||||
$this->timeFromHourMin($hBegin, $mBegin, $now) <= $now
|
||||
&& $this->timeFromHourMin($hEnd, $mEnd, $now) >= $now
|
||||
) {
|
||||
return true;
|
||||
|
|
|
@ -307,7 +307,8 @@ class IcingaService extends IcingaObject implements ExportInterface
|
|||
|
||||
$str = parent::toLegacyConfigString();
|
||||
|
||||
if (! $this->isDisabled()
|
||||
if (
|
||||
! $this->isDisabled()
|
||||
&& $this->get('host_id')
|
||||
&& $this->getRelated('host')->isDisabled()
|
||||
) {
|
||||
|
@ -329,7 +330,8 @@ class IcingaService extends IcingaObject implements ExportInterface
|
|||
}
|
||||
$str = parent::toConfigString();
|
||||
|
||||
if (! $this->isDisabled()
|
||||
if (
|
||||
! $this->isDisabled()
|
||||
&& $this->get('host_id')
|
||||
&& $this->getRelated('host')->isDisabled()
|
||||
) {
|
||||
|
@ -346,7 +348,8 @@ class IcingaService extends IcingaObject implements ExportInterface
|
|||
*/
|
||||
protected function renderObjectHeader()
|
||||
{
|
||||
if ($this->isApplyRule()
|
||||
if (
|
||||
$this->isApplyRule()
|
||||
&& !$this->hasBeenAssignedToHostTemplate()
|
||||
&& $this->get('apply_for') !== null
|
||||
) {
|
||||
|
@ -609,7 +612,8 @@ class IcingaService extends IcingaObject implements ExportInterface
|
|||
{
|
||||
$where = parent::createWhere();
|
||||
if (! $this->hasBeenLoadedFromDb()) {
|
||||
if (null === $this->get('service_set_id')
|
||||
if (
|
||||
null === $this->get('service_set_id')
|
||||
&& null === $this->get('host_id')
|
||||
&& null === $this->get('id')
|
||||
) {
|
||||
|
@ -717,7 +721,8 @@ class IcingaService extends IcingaObject implements ExportInterface
|
|||
protected function beforeStore()
|
||||
{
|
||||
parent::beforeStore();
|
||||
if ($this->isObject()
|
||||
if (
|
||||
$this->isObject()
|
||||
&& $this->get('service_set_id') === null
|
||||
&& $this->get('host_id') === null
|
||||
) {
|
||||
|
|
|
@ -47,7 +47,8 @@ class IcingaTimePeriodRange extends DbObject
|
|||
{
|
||||
$hBegin = $mBegin = $hEnd = $mEnd = null;
|
||||
if (sscanf($rangeString, '%2d:%2d-%2d:%2d', $hBegin, $mBegin, $hEnd, $mEnd) === 4) {
|
||||
if ($this->timeFromHourMin($hBegin, $mBegin, $now) <= $now
|
||||
if (
|
||||
$this->timeFromHourMin($hBegin, $mBegin, $now) <= $now
|
||||
&& $this->timeFromHourMin($hEnd, $mEnd, $now) >= $now
|
||||
) {
|
||||
return true;
|
||||
|
|
|
@ -45,7 +45,7 @@ class ImportRowModifier extends DbObjectWithSettings implements InstantiatedViaH
|
|||
$class
|
||||
));
|
||||
}
|
||||
$obj = new $class;
|
||||
$obj = new $class();
|
||||
$obj->setSettings($this->getSettings());
|
||||
$obj->setPropertyName($this->get('property_name'));
|
||||
$obj->setTargetProperty($this->get('target_property'));
|
||||
|
|
|
@ -132,7 +132,7 @@ class ImportSource extends DbObjectWithSettings implements ExportInterface
|
|||
protected static function existsWithNameAndId($name, $id, Db $connection)
|
||||
{
|
||||
$db = $connection->getDbAdapter();
|
||||
$dummy = new static;
|
||||
$dummy = new static();
|
||||
$idCol = $dummy->autoincKeyName;
|
||||
$keyCol = $dummy->keyName;
|
||||
|
||||
|
|
|
@ -487,7 +487,7 @@ class SyncRule extends DbObject implements ExportInterface
|
|||
protected static function existsWithNameAndId($name, $id, Db $connection)
|
||||
{
|
||||
$db = $connection->getDbAdapter();
|
||||
$dummy = new static;
|
||||
$dummy = new static();
|
||||
$idCol = $dummy->autoincKeyName;
|
||||
$keyCol = $dummy->keyName;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\PropertyModifier;
|
|||
|
||||
use Icinga\Exception\InvalidPropertyException;
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
|
||||
use function array_unique;
|
||||
use function array_values;
|
||||
use function is_array;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Director\PropertyModifier;
|
||||
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
|
||||
use function iconv;
|
||||
|
||||
class PropertyModifierFromLatin1 extends PropertyModifierHook
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Director\PropertyModifier;
|
||||
|
||||
use Icinga\Module\Director\Hook\PropertyModifierHook;
|
||||
|
||||
use function ipl\Stdlib\get_php_type;
|
||||
|
||||
class PropertyModifierNegateBoolean extends PropertyModifierHook
|
||||
|
|
|
@ -8,7 +8,6 @@ use Icinga\Module\Director\Web\Form\QuickForm;
|
|||
|
||||
class PropertyModifierParseURL extends PropertyModifierHook
|
||||
{
|
||||
|
||||
/**
|
||||
* Array with possible components that can be returned from URL.
|
||||
*/
|
||||
|
|
|
@ -7,7 +7,6 @@ use Icinga\Module\Director\Web\Form\QuickForm;
|
|||
|
||||
class PropertyModifierReplaceNull extends PropertyModifierHook
|
||||
{
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'Replace null value with String';
|
||||
|
|
|
@ -6,5 +6,4 @@ use Icinga\Module\Icingadb\Hook\IcingadbSupportHook;
|
|||
|
||||
class IcingadbSupport extends IcingadbSupportHook
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -80,7 +80,8 @@ class HostServiceBlacklist
|
|||
|
||||
public function getPreLoadedMappingsForService(IcingaService $service)
|
||||
{
|
||||
if ($this->mappings !== null
|
||||
if (
|
||||
$this->mappings !== null
|
||||
&& array_key_exists($service->get('id'), $this->mappings)
|
||||
) {
|
||||
return $this->mappings[$service->get('id')];
|
||||
|
|
|
@ -137,7 +137,8 @@ class TemplateTree
|
|||
|
||||
public function getAncestorsFor(IcingaObject $object)
|
||||
{
|
||||
if ($object->hasBeenModified()
|
||||
if (
|
||||
$object->hasBeenModified()
|
||||
&& $object->gotImports()
|
||||
&& $object->imports()->hasBeenModified()
|
||||
) {
|
||||
|
|
|
@ -50,7 +50,8 @@ abstract class ActionController extends Controller implements ControlsAndContent
|
|||
*/
|
||||
public function init()
|
||||
{
|
||||
if (! $this->getRequest()->isApiRequest()
|
||||
if (
|
||||
! $this->getRequest()->isApiRequest()
|
||||
&& $this->Config()->get('frontend', 'disabled', 'no') === 'yes'
|
||||
) {
|
||||
throw new NotFoundError('Not found');
|
||||
|
|
|
@ -174,7 +174,8 @@ abstract class ObjectController extends ActionController
|
|||
$this->tabs()->activate('modify');
|
||||
$this->addObjectTitle();
|
||||
// Hint: Service Sets are 'templates' (as long as not being assigned to a host
|
||||
if ($this->getTableName() !== 'icinga_service_set'
|
||||
if (
|
||||
$this->getTableName() !== 'icinga_service_set'
|
||||
&& $object->isTemplate()
|
||||
&& $this->showNotInBranch($this->translate('Modifying Templates'))
|
||||
) {
|
||||
|
@ -460,7 +461,8 @@ abstract class ObjectController extends ActionController
|
|||
|
||||
protected function redirectToPreviewForExternals()
|
||||
{
|
||||
if ($this->object
|
||||
if (
|
||||
$this->object
|
||||
&& $this->object->isExternal()
|
||||
&& ! in_array($this->object->getShortTableName(), $this->allowedExternals)
|
||||
) {
|
||||
|
@ -566,7 +568,8 @@ abstract class ObjectController extends ActionController
|
|||
}
|
||||
if ($showHint) {
|
||||
$hasPreferredBranch = $this->hasPreferredBranch();
|
||||
if (($hasPreferredBranch || $branch->isBranch())
|
||||
if (
|
||||
($hasPreferredBranch || $branch->isBranch())
|
||||
&& $object->isObject()
|
||||
&& ! $this->getRequest()->isApiRequest()
|
||||
) {
|
||||
|
|
|
@ -73,7 +73,8 @@ abstract class ObjectsController extends ActionController
|
|||
{
|
||||
$request = $this->getRequest();
|
||||
$table = $this->getTable();
|
||||
if ($request->getControllerName() === 'services'
|
||||
if (
|
||||
$request->getControllerName() === 'services'
|
||||
&& $host = $this->params->get('host')
|
||||
) {
|
||||
$host = IcingaHost::load($host, $this->db());
|
||||
|
|
|
@ -37,7 +37,8 @@ class StoredPassword extends ZfText
|
|||
|
||||
public function setValue($value)
|
||||
{
|
||||
if (\is_array($value) && isset($value['_value'], $value['_sent'])
|
||||
if (
|
||||
\is_array($value) && isset($value['_value'], $value['_sent'])
|
||||
&& $value['_sent'] === 'y'
|
||||
) {
|
||||
$value = $sentValue = $value['_value'];
|
||||
|
|
|
@ -568,7 +568,7 @@ class IcingaObjectFieldLoader
|
|||
$id = $r->object_id;
|
||||
unset($r->object_id);
|
||||
if (! array_key_exists($id, $result)) {
|
||||
$result[$id] = new stdClass;
|
||||
$result[$id] = new stdClass();
|
||||
}
|
||||
|
||||
$result[$id]->{$r->varname} = DirectorDatafield::fromDbRow(
|
||||
|
|
|
@ -47,7 +47,7 @@ class IconHelper
|
|||
public static function instance()
|
||||
{
|
||||
if (self::$instance === null) {
|
||||
self::$instance = new static;
|
||||
self::$instance = new static();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
|
|
|
@ -54,7 +54,8 @@ class DeploymentLogTable extends IntlZfQueryBasedTable
|
|||
$classes = ['notsent'];
|
||||
}
|
||||
|
||||
if ($this->activeStageName !== null
|
||||
if (
|
||||
$this->activeStageName !== null
|
||||
&& $row->stage_name === $this->activeStageName
|
||||
) {
|
||||
$classes[] = 'running';
|
||||
|
|
|
@ -82,7 +82,7 @@ class PropertymodifierTable extends ZfQueryBasedTable
|
|||
$class = $row->provider_class;
|
||||
try {
|
||||
/** @var ImportSourceHook $hook */
|
||||
$hook = new $class;
|
||||
$hook = new $class();
|
||||
$caption .= ': ' . $hook->getName();
|
||||
} catch (Exception $e) {
|
||||
$caption = $this->createErrorCaption($caption, $e);
|
||||
|
|
|
@ -7,7 +7,6 @@ use Ramsey\Uuid\UuidInterface;
|
|||
|
||||
trait TableWithBranchSupport
|
||||
{
|
||||
|
||||
/** @var UuidInterface|null */
|
||||
protected $branchUuid;
|
||||
|
||||
|
|
|
@ -102,7 +102,8 @@ class ObjectTabs extends Tabs
|
|||
}
|
||||
|
||||
// TODO: remove table check once we resolve all group types
|
||||
if ($object->isGroup() &&
|
||||
if (
|
||||
$object->isGroup() &&
|
||||
($object->getShortTableName() === 'hostgroup' || $object->getShortTableName() === 'servicegroup')
|
||||
) {
|
||||
$this->add('membership', [
|
||||
|
@ -120,7 +121,8 @@ class ObjectTabs extends Tabs
|
|||
]);
|
||||
}
|
||||
|
||||
if ($object->getShortTableName() === 'endpoint'
|
||||
if (
|
||||
$object->getShortTableName() === 'endpoint'
|
||||
&& $object->get('apiuser_id')
|
||||
) {
|
||||
$this->add('inspect', [
|
||||
|
|
|
@ -37,14 +37,16 @@ class ObjectsTabs extends Tabs
|
|||
]);
|
||||
}
|
||||
|
||||
if ($auth->hasPermission(Permission::ADMIN)
|
||||
if (
|
||||
$auth->hasPermission(Permission::ADMIN)
|
||||
|| (
|
||||
$object->getShortTableName() === 'notification'
|
||||
&& $auth->hasPermission(Permission::NOTIFICATIONS)
|
||||
) || (
|
||||
$object->getShortTableName() === 'scheduled_downtime'
|
||||
&& $auth->hasPermission(Permission::SCHEDULED_DOWNTIMES)
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
if ($object->supportsApplyRules()) {
|
||||
$this->add('applyrules', [
|
||||
'url' => sprintf('director/%s/applyrules', $plType),
|
||||
|
|
|
@ -227,7 +227,7 @@ class ActivityLogInfo extends HtmlDocument
|
|||
$this->oldProperties = JsonString::decodeOptional($this->entry->old_properties);
|
||||
}
|
||||
if ($this->oldProperties === null) {
|
||||
$this->oldProperties = new \stdClass;
|
||||
$this->oldProperties = new \stdClass();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ class ActivityLogInfo extends HtmlDocument
|
|||
$this->newProperties = JsonString::decodeOptional($this->entry->new_properties);
|
||||
}
|
||||
if ($this->newProperties === null) {
|
||||
$this->newProperties = new \stdClass;
|
||||
$this->newProperties = new \stdClass();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,10 +373,12 @@ class ActivityLogInfo extends HtmlDocument
|
|||
$this->defaultTab = 'diff';
|
||||
}
|
||||
|
||||
if (in_array($entry->action_name, [
|
||||
if (
|
||||
in_array($entry->action_name, [
|
||||
DirectorActivityLog::ACTION_CREATE,
|
||||
DirectorActivityLog::ACTION_MODIFY,
|
||||
])) {
|
||||
])
|
||||
) {
|
||||
$tabs->add('new', [
|
||||
'label' => $this->translate('New object'),
|
||||
'url' => $url->with(['id' => $entry->id, 'show' => 'new'])
|
||||
|
@ -387,10 +389,12 @@ class ActivityLogInfo extends HtmlDocument
|
|||
}
|
||||
}
|
||||
|
||||
if (in_array($entry->action_name, [
|
||||
if (
|
||||
in_array($entry->action_name, [
|
||||
DirectorActivityLog::ACTION_DELETE,
|
||||
DirectorActivityLog::ACTION_MODIFY,
|
||||
])) {
|
||||
])
|
||||
) {
|
||||
$tabs->add('old', [
|
||||
'label' => $this->translate('Former object'),
|
||||
'url' => $url->with(['id' => $entry->id, 'show' => 'old'])
|
||||
|
|
|
@ -9,6 +9,7 @@ use Icinga\Module\Director\Objects\SyncRun;
|
|||
use gipfl\IcingaWeb2\Link;
|
||||
use gipfl\Translation\TranslationHelper;
|
||||
use gipfl\IcingaWeb2\Widget\NameValueTable;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
class SyncRunDetails extends NameValueTable
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
|
|
Loading…
Reference in New Issue