N°2013 Setup : fix crash on setting readonly mode if initial DB info were wrong

Same as 15d3201a, but this error happened before compilation, when setting read only mode.
As before this is another fix for #351.

This fix introduces the new method \WizardController::GetParamForConfigArray
I replaced existing duplicate code with a call to this new generic method.
This commit is contained in:
Pierre Goiffon
2023-01-10 10:11:24 +01:00
parent d3d89b1ee2
commit 43d86ad8e2
6 changed files with 52 additions and 56 deletions

View File

@@ -75,15 +75,37 @@ class WizardController
*/
public function GetParameter($sParamCode, $defaultValue = '')
{
if (array_key_exists($sParamCode, $this->aParameters))
{
if (array_key_exists($sParamCode, $this->aParameters)) {
return $this->aParameters[$sParamCode];
}
return $defaultValue;
}
/**
* @return array Allow to update config using {@see Config::UpdateFromParams()}
*
* @since 3.1.0 N°2013
*/
public function GetParamForConfigArray(): array
{
/** @noinspection PhpUnnecessaryLocalVariableInspection */
$aParamValues = array(
'db_server' => $this->GetParameter('db_server', ''),
'db_user' => $this->GetParameter('db_user', ''),
'db_pwd' => $this->GetParameter('db_pwd', ''),
'db_name' => $this->GetParameter('db_name', ''),
'db_prefix' => $this->GetParameter('db_prefix', ''),
'db_tls_enabled' => $this->GetParameter('db_tls_enabled', false),
'db_tls_ca' => $this->GetParameter('db_tls_ca', ''),
);
return $aParamValues;
}
/**
* Stores a "persistent" parameter in the wizard's context
*
* @param string $sParamCode The code identifying this parameter
* @param mixed $value The value to store
*/