Skip to content

Commit 3c72286

Browse files
authored
Print redis config file if saving failed (#1272)
If saving the Redis settings fails due to a write error, the desired configuration file content is now displayed so that the user can deploy it manually (Same behavior as with database configuration). For that a catch block is introduced on the `NotWritableError` that is added to `IniWriter::write()` in Icinga/icingaweb2#5404. Refs Icinga/icingaweb2#5404 Resolves #1269
1 parent c7cc328 commit 3c72286

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

application/forms/RedisConfigForm.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use ipl\Validator\PrivateKeyValidator;
2121
use ipl\Validator\X509CertValidator;
2222
use Throwable;
23+
use Zend_Config_Exception;
24+
use Zend_Form_Decorator_Abstract;
2325
use Zend_Validate_Callback;
2426

2527
class RedisConfigForm extends ConfigForm
@@ -537,6 +539,17 @@ public function onSuccess()
537539

538540
try {
539541
$connectionConfig->saveIni();
542+
} catch (NotWritableError | Zend_Config_Exception $e) {
543+
$this->addDecorator('ViewScript', array(
544+
'viewModule' => 'default',
545+
'viewScript' => 'showConfiguration.phtml',
546+
'errorMessage' => $e->getMessage(),
547+
'configString' => $connectionConfig,
548+
'filePath' => $connectionConfig->getConfigFile(),
549+
'placement' => Zend_Form_Decorator_Abstract::PREPEND
550+
));
551+
552+
return false;
540553
} catch (Throwable $e) {
541554
$this->addError($e->getMessage());
542555
Logger::error($e->getMessage());

0 commit comments

Comments
 (0)