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
https://github.com/Icinga/icingaweb2/pull/5404.

Refs https://github.com/Icinga/icingaweb2/pull/5404
Resolves #1269
This commit is contained in:
jrauh01 2025-11-17 13:19:13 +01:00 committed by GitHub
parent c7cc328bf2
commit 3c7228686c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,8 @@ use Icinga\Web\Form;
use ipl\Validator\PrivateKeyValidator;
use ipl\Validator\X509CertValidator;
use Throwable;
use Zend_Config_Exception;
use Zend_Form_Decorator_Abstract;
use Zend_Validate_Callback;
class RedisConfigForm extends ConfigForm
@ -537,6 +539,17 @@ class RedisConfigForm extends ConfigForm
try {
$connectionConfig->saveIni();
} catch (NotWritableError | Zend_Config_Exception $e) {
$this->addDecorator('ViewScript', array(
'viewModule' => 'default',
'viewScript' => 'showConfiguration.phtml',
'errorMessage' => $e->getMessage(),
'configString' => $connectionConfig,
'filePath' => $connectionConfig->getConfigFile(),
'placement' => Zend_Form_Decorator_Abstract::PREPEND
));
return false;
} catch (Throwable $e) {
$this->addError($e->getMessage());
Logger::error($e->getMessage());