diff options
Diffstat (limited to '')
-rw-r--r-- | library/Director/Core/CoreApi.php | 4 | ||||
-rw-r--r-- | library/Director/Core/LegacyDeploymentApi.php | 10 | ||||
-rw-r--r-- | library/Director/Core/RestApiClient.php | 14 | ||||
-rw-r--r-- | library/Director/Core/RestApiResponse.php | 2 |
4 files changed, 16 insertions, 14 deletions
diff --git a/library/Director/Core/CoreApi.php b/library/Director/Core/CoreApi.php index ea10916..73588c2 100644 --- a/library/Director/Core/CoreApi.php +++ b/library/Director/Core/CoreApi.php @@ -569,7 +569,7 @@ constants 'icon_image_alt' => 'icon_image_alt', ]; - if (version_compare($this->getVersion(), '2.8.0', '>=')) { + if (version_compare($this->getVersion() ?? '', '2.8.0', '>=')) { $params['flapping_threshold_high'] = 'flapping_threshold_high'; $params['flapping_threshold_low'] = 'flapping_threshold_low'; } @@ -622,7 +622,7 @@ constants { IcingaCommand::setPluginDir($this->getConstant('PluginDir')); - $objects = $this->getDirectorObjects('Command', "${type}Commands", [ + $objects = $this->getDirectorObjects('Command', "{$type}Commands", [ 'arguments' => 'arguments', // 'env' => 'env', 'timeout' => 'timeout', diff --git a/library/Director/Core/LegacyDeploymentApi.php b/library/Director/Core/LegacyDeploymentApi.php index 7287c4a..0ab77e0 100644 --- a/library/Director/Core/LegacyDeploymentApi.php +++ b/library/Director/Core/LegacyDeploymentApi.php @@ -128,6 +128,10 @@ class LegacyDeploymentApi implements DeploymentApiInterface if (file_exists($path)) { if (is_link($path)) { $linkTarget = readlink($path); + if (! $linkTarget) { + throw new IcingaException('Failed to read symlink'); + } + $linkTargetDir = dirname($linkTarget); $linkTargetName = basename($linkTarget); @@ -165,7 +169,7 @@ class LegacyDeploymentApi implements DeploymentApiInterface $this->assertDeploymentPath(); $dh = @opendir($this->deploymentPath); - if ($dh === null) { + if ($dh === false) { throw new IcingaException('Can not list contents of %s', $this->deploymentPath); } @@ -279,7 +283,7 @@ class LegacyDeploymentApi implements DeploymentApiInterface $this->mkdir(dirname($fullPath), true); $fh = @fopen($fullPath, 'w'); - if ($fh === null) { + if ($fh === false) { throw new IcingaException('Could not open file "%s" for writing.', $fullPath); } chmod($fullPath, $this->file_mode); @@ -334,7 +338,7 @@ class LegacyDeploymentApi implements DeploymentApiInterface protected function listDirectoryContents($path, $depth = 0) { $dh = @opendir($path); - if ($dh === null) { + if ($dh === false) { throw new IcingaException('Can not list contents of %s', $path); } diff --git a/library/Director/Core/RestApiClient.php b/library/Director/Core/RestApiClient.php index b0854ff..19f6b68 100644 --- a/library/Director/Core/RestApiClient.php +++ b/library/Director/Core/RestApiClient.php @@ -206,14 +206,14 @@ class RestApiClient } /** - * @return resource + * @throws RuntimeException */ protected function curl() { if ($this->curl === null) { $this->curl = curl_init(sprintf('https://%s:%d', $this->peer, $this->port)); if (! $this->curl) { - throw new RuntimeException('CURL INIT ERROR: ' . curl_error($this->curl)); + throw new RuntimeException('CURL INIT FAILED'); } } @@ -260,13 +260,11 @@ class RestApiClient public function disconnect() { - if ($this->curl !== null) { - if (is_resource($this->curl)) { - @curl_close($this->curl); - } - - $this->curl = null; + if ($this->curl) { + @curl_close($this->curl); } + + $this->curl = null; } public function __destruct() diff --git a/library/Director/Core/RestApiResponse.php b/library/Director/Core/RestApiResponse.php index 523ed35..43516f7 100644 --- a/library/Director/Core/RestApiResponse.php +++ b/library/Director/Core/RestApiResponse.php @@ -113,7 +113,7 @@ class RestApiResponse throw new IcingaException('API request failed: ' . $result->status); } } else { - throw new IcingaException('API request failed: ' . var_export($result, 1)); + throw new IcingaException('API request failed: ' . var_export($result, true)); } } |