Open tetrode opened 7 years ago
Adding the possibility to also propagate the comments when writing the ini file. Works as follows:
$ini = 'piwik.ini'; $reader = new \Piwik\Ini\IniReader(); $config = $reader->readFile($ini); $comments = $reader->readComments($ini); $writer = new \Piwik\Ini\IniWriter(); $writer->writeToFile('piwik-new.ini', $config, '', $comments);
Things that do not work:
1 pre-section comments disappear: ; section comment [MySection] ; option comment myOption = 1
becomes [MySection] ; option comment myOption = 1
2 Individual array comments disappear: [MySection] ; comment a ar[] = "a" ; comment b ar[] = "b" ; comment c ar[] = "c"
becomes [MySection] ; comment a ar[] = "a" ar[] = "b" ar[] = "c"
Coverage decreased (-11.7%) to 70.673% when pulling a37cd9f9db04cd814e30f36f5d683ff03a7849ec on tetrode:patch-1 into bd2711ba4d5e20e4ca09b6829dc2831576b59dc3 on piwik:master.
Thanks for the PR @tetrode
Could you please add some unit/integration tests, to make sure your feature will not break in the future?
Adding the possibility to also propagate the comments when writing the ini file. Works as follows:
$ini = 'piwik.ini'; $reader = new \Piwik\Ini\IniReader(); $config = $reader->readFile($ini); $comments = $reader->readComments($ini); $writer = new \Piwik\Ini\IniWriter(); $writer->writeToFile('piwik-new.ini', $config, '', $comments);
Things that do not work:
1 pre-section comments disappear: ; section comment [MySection] ; option comment myOption = 1
becomes [MySection] ; option comment myOption = 1
2 Individual array comments disappear: [MySection] ; comment a ar[] = "a" ; comment b ar[] = "b" ; comment c ar[] = "c"
becomes [MySection] ; comment a ar[] = "a" ar[] = "b" ar[] = "c"