Wizard: Transform emtpy page data values to null

Previously the wizard wrote empty strings to config files.
This commit is contained in:
Johannes Meyer 2021-06-30 18:53:41 +02:00
parent 8b7a3f05af
commit 53c0d6de86
2 changed files with 8 additions and 1 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Web;
use Icinga\Forms\ConfigForm;
use LogicException;
use InvalidArgumentException;
use Icinga\Web\Session\SessionNamespace;
@ -286,7 +287,7 @@ class Wizard
if ($isValid) {
$pageData = & $this->getPageData();
$pageData[$page->getName()] = $page->getValues();
$pageData[$page->getName()] = ConfigForm::transformEmptyValuesToNull($page->getValues());
$this->setCurrentPage($this->getNewPage($requestedPage, $page));
$page->getResponse()->redirectAndExit($page->getRedirectUrl());
}

View File

@ -121,6 +121,12 @@ class DbTool
*/
public function __construct(array $config)
{
if (! isset($config['port'])) {
// TODO: This is not quite correct, but works as it previously did. Previously empty values were not
// transformed no NULL (now they are) so if the port is now null, it's been the empty string.
$config['port'] = '';
}
$this->config = $config;
}