diff --git a/library/Icinga/Config/IniEditor.php b/library/Icinga/Config/IniEditor.php index 4e67f7c2a..b9d7a986e 100644 --- a/library/Icinga/Config/IniEditor.php +++ b/library/Icinga/Config/IniEditor.php @@ -396,10 +396,12 @@ class IniEditor private function updateLine($lineNr, $content) { $comment = $this->getComment($this->text[$lineNr]); + $comment = trim($comment); if (strlen($comment) > 0) { - $comment = ' ; ' . trim($comment); + $comment = ' ; ' . $comment; + $content = str_pad($content, $this->commentIndentation) . $comment; } - $this->text[$lineNr] = str_pad($content, $this->commentIndentation) . $comment; + $this->text[$lineNr] = $content; } /** diff --git a/test/php/library/Icinga/Config/PreservingIniWriterTest.php b/test/php/library/Icinga/Config/PreservingIniWriterTest.php index daa1ce005..5e64efe39 100644 --- a/test/php/library/Icinga/Config/PreservingIniWriterTest.php +++ b/test/php/library/Icinga/Config/PreservingIniWriterTest.php @@ -121,8 +121,8 @@ prop2="5" /** * Write a string to a temporary file * - * @param $name The name of the temporary file - * @param $content The content + * @param string $name The name of the temporary file + * @param string $content The content */ private function writeToTmp($name, $content) { @@ -236,10 +236,10 @@ property = "something" ; comment } /** - * Change the test config and write the changes to the temporary - * file $tmpFile + * Change the test config, write the changes to the temporary + * file $tmpFile and save the path to the file in the array tmpfiles * - * @param $tmpFile + * @param string $tmpFile The name that should be given to the temporary file */ private function changeConfigAndWriteToFile($tmpFile) { @@ -277,7 +277,7 @@ property = "something" ; comment /** * Test if all configuration properties are set correctly * - * @param $config + * @param mixed $config The configuration to check */ private function checkConfigProperties($config) { @@ -344,9 +344,9 @@ property = "something" ; comment } /** - * Change the content of a Zend_Config + * Change the content of a Zend_Config for testing purposes * - * @param Zend_Config $config + * @param Zend_Config $config The configuration that should be changed */ private function alterConfig(\Zend_Config $config) {