Replace temp variable with property

This commit is contained in:
Art4 2024-11-10 08:53:36 +00:00
parent 81c0c56e5a
commit 79f9e78daf

View file

@ -59,8 +59,8 @@ class Install extends BaseModule
*/ */
private $installer; private $installer;
/** @var AppHelper */ /** @var Cache */
protected $appHelper; protected $configCache;
/** @var Mode */ /** @var Mode */
protected $mode; protected $mode;
@ -68,7 +68,7 @@ class Install extends BaseModule
{ {
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->appHelper = $appHelper; $this->configCache = $appHelper->getConfigCache();
$this->mode = $mode; $this->mode = $mode;
$this->installer = $installer; $this->installer = $installer;
@ -84,8 +84,7 @@ class Install extends BaseModule
} }
// get basic installation information and save them to the config cache // get basic installation information and save them to the config cache
$configCache = $this->appHelper->getConfigCache(); $this->installer->setUpCache($this->configCache, $basePath->getPath());
$this->installer->setUpCache($configCache, $basePath->getPath());
// We overwrite current theme css, because during install we may not have a working mod_rewrite // We overwrite current theme css, because during install we may not have a working mod_rewrite
// so we may not have a css at all. Here we set a static css file for the install procedure pages // so we may not have a css at all. Here we set a static css file for the install procedure pages
@ -96,31 +95,29 @@ class Install extends BaseModule
protected function post(array $request = []) protected function post(array $request = [])
{ {
$configCache = $this->appHelper->getConfigCache();
switch ($this->currentWizardStep) { switch ($this->currentWizardStep) {
case self::SYSTEM_CHECK: case self::SYSTEM_CHECK:
case self::BASE_CONFIG: case self::BASE_CONFIG:
$this->checkSetting($configCache, $_POST, 'config', 'php_path'); $this->checkSetting($this->configCache, $_POST, 'config', 'php_path');
break; break;
case self::DATABASE_CONFIG: case self::DATABASE_CONFIG:
$this->checkSetting($configCache, $_POST, 'config', 'php_path'); $this->checkSetting($this->configCache, $_POST, 'config', 'php_path');
$this->checkSetting($configCache, $_POST, 'system', 'basepath'); $this->checkSetting($this->configCache, $_POST, 'system', 'basepath');
$this->checkSetting($configCache, $_POST, 'system', 'url'); $this->checkSetting($this->configCache, $_POST, 'system', 'url');
break; break;
case self::SITE_SETTINGS: case self::SITE_SETTINGS:
$this->checkSetting($configCache, $_POST, 'config', 'php_path'); $this->checkSetting($this->configCache, $_POST, 'config', 'php_path');
$this->checkSetting($configCache, $_POST, 'system', 'basepath'); $this->checkSetting($this->configCache, $_POST, 'system', 'basepath');
$this->checkSetting($configCache, $_POST, 'system', 'url'); $this->checkSetting($this->configCache, $_POST, 'system', 'url');
$this->checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST); $this->checkSetting($this->configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST);
$this->checkSetting($configCache, $_POST, 'database', 'username', ''); $this->checkSetting($this->configCache, $_POST, 'database', 'username', '');
$this->checkSetting($configCache, $_POST, 'database', 'password', ''); $this->checkSetting($this->configCache, $_POST, 'database', 'password', '');
$this->checkSetting($configCache, $_POST, 'database', 'database', ''); $this->checkSetting($this->configCache, $_POST, 'database', 'database', '');
// If we cannot connect to the database, return to the previous step // If we cannot connect to the database, return to the previous step
if (!$this->installer->checkDB(DI::dba())) { if (!$this->installer->checkDB(DI::dba())) {
@ -130,19 +127,19 @@ class Install extends BaseModule
break; break;
case self::FINISHED: case self::FINISHED:
$this->checkSetting($configCache, $_POST, 'config', 'php_path'); $this->checkSetting($this->configCache, $_POST, 'config', 'php_path');
$this->checkSetting($configCache, $_POST, 'system', 'basepath'); $this->checkSetting($this->configCache, $_POST, 'system', 'basepath');
$this->checkSetting($configCache, $_POST, 'system', 'url'); $this->checkSetting($this->configCache, $_POST, 'system', 'url');
$this->checkSetting($configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST); $this->checkSetting($this->configCache, $_POST, 'database', 'hostname', Core\Installer::DEFAULT_HOST);
$this->checkSetting($configCache, $_POST, 'database', 'username', ''); $this->checkSetting($this->configCache, $_POST, 'database', 'username', '');
$this->checkSetting($configCache, $_POST, 'database', 'password', ''); $this->checkSetting($this->configCache, $_POST, 'database', 'password', '');
$this->checkSetting($configCache, $_POST, 'database', 'database', ''); $this->checkSetting($this->configCache, $_POST, 'database', 'database', '');
$this->checkSetting($configCache, $_POST, 'system', 'default_timezone', Core\Installer::DEFAULT_TZ); $this->checkSetting($this->configCache, $_POST, 'system', 'default_timezone', Core\Installer::DEFAULT_TZ);
$this->checkSetting($configCache, $_POST, 'system', 'language', Core\Installer::DEFAULT_LANG); $this->checkSetting($this->configCache, $_POST, 'system', 'language', Core\Installer::DEFAULT_LANG);
$this->checkSetting($configCache, $_POST, 'config', 'admin_email', ''); $this->checkSetting($this->configCache, $_POST, 'config', 'admin_email', '');
// If we cannot connect to the database, return to the Database config wizard // If we cannot connect to the database, return to the Database config wizard
if (!$this->installer->checkDB(DI::dba())) { if (!$this->installer->checkDB(DI::dba())) {
@ -150,7 +147,7 @@ class Install extends BaseModule
return; return;
} }
if (!$this->installer->createConfig($configCache)) { if (!$this->installer->createConfig($this->configCache)) {
return; return;
} }
@ -172,15 +169,13 @@ class Install extends BaseModule
protected function content(array $request = []): string protected function content(array $request = []): string
{ {
$configCache = $this->appHelper->getConfigCache();
$output = ''; $output = '';
$install_title = $this->t('Friendica Communications Server - Setup'); $install_title = $this->t('Friendica Communications Server - Setup');
switch ($this->currentWizardStep) { switch ($this->currentWizardStep) {
case self::SYSTEM_CHECK: case self::SYSTEM_CHECK:
$php_path = $configCache->get('config', 'php_path'); $php_path = $this->configCache->get('config', 'php_path');
$status = $this->installer->checkEnvironment($this->baseUrl, $php_path); $status = $this->installer->checkEnvironment($this->baseUrl, $php_path);
@ -202,8 +197,8 @@ class Install extends BaseModule
break; break;
case self::BASE_CONFIG: case self::BASE_CONFIG:
$baseUrl = $configCache->get('system', 'url') ? $baseUrl = $this->configCache->get('system', 'url') ?
new Uri($configCache->get('system', 'url')) : new Uri($this->configCache->get('system', 'url')) :
$this->baseUrl; $this->baseUrl;
$tpl = Renderer::getMarkupTemplate('install/02_base_config.tpl'); $tpl = Renderer::getMarkupTemplate('install/02_base_config.tpl');
@ -212,7 +207,7 @@ class Install extends BaseModule
'$pass' => $this->t('Base settings'), '$pass' => $this->t('Base settings'),
'$basepath' => ['system-basepath', '$basepath' => ['system-basepath',
$this->t("Base path to installation"), $this->t("Base path to installation"),
$configCache->get('system', 'basepath'), $this->configCache->get('system', 'basepath'),
$this->t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot."), $this->t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot."),
$this->t('Required')], $this->t('Required')],
'$system_url' => ['system-url', '$system_url' => ['system-url',
@ -220,7 +215,7 @@ class Install extends BaseModule
(string)$baseUrl, (string)$baseUrl,
$this->t("Overwrite this field in case the system URL determination isn't right, otherwise leave it as is."), $this->t("Overwrite this field in case the system URL determination isn't right, otherwise leave it as is."),
$this->t('Required')], $this->t('Required')],
'$php_path' => $configCache->get('config', 'php_path'), '$php_path' => $this->configCache->get('config', 'php_path'),
'$submit' => $this->t('Submit'), '$submit' => $this->t('Submit'),
]); ]);
break; break;
@ -236,31 +231,31 @@ class Install extends BaseModule
'$required' => $this->t('Required'), '$required' => $this->t('Required'),
'$requirement_not_satisfied' => $this->t('Requirement not satisfied'), '$requirement_not_satisfied' => $this->t('Requirement not satisfied'),
'$checks' => $this->installer->getChecks(), '$checks' => $this->installer->getChecks(),
'$basepath' => $configCache->get('system', 'basepath'), '$basepath' => $this->configCache->get('system', 'basepath'),
'$system_url' => $configCache->get('system', 'url'), '$system_url' => $this->configCache->get('system', 'url'),
'$dbhost' => ['database-hostname', '$dbhost' => ['database-hostname',
$this->t('Database Server Name'), $this->t('Database Server Name'),
$configCache->get('database', 'hostname'), $this->configCache->get('database', 'hostname'),
'', '',
$this->t('Required')], $this->t('Required')],
'$dbuser' => ['database-username', '$dbuser' => ['database-username',
$this->t('Database Login Name'), $this->t('Database Login Name'),
$configCache->get('database', 'username'), $this->configCache->get('database', 'username'),
'', '',
$this->t('Required'), $this->t('Required'),
'autofocus'], 'autofocus'],
'$dbpass' => ['database-password', '$dbpass' => ['database-password',
$this->t('Database Login Password'), $this->t('Database Login Password'),
$configCache->get('database', 'password'), $this->configCache->get('database', 'password'),
$this->t("For security reasons the password must not be empty"), $this->t("For security reasons the password must not be empty"),
$this->t('Required')], $this->t('Required')],
'$dbdata' => ['database-database', '$dbdata' => ['database-database',
$this->t('Database Name'), $this->t('Database Name'),
$configCache->get('database', 'database'), $this->configCache->get('database', 'database'),
'', '',
$this->t('Required')], $this->t('Required')],
'$lbl_10' => $this->t('Please select a default timezone for your website'), '$lbl_10' => $this->t('Please select a default timezone for your website'),
'$php_path' => $configCache->get('config', 'php_path'), '$php_path' => $this->configCache->get('config', 'php_path'),
'$submit' => $this->t('Submit') '$submit' => $this->t('Submit')
]); ]);
break; break;
@ -275,27 +270,27 @@ class Install extends BaseModule
'$required' => $this->t('Required'), '$required' => $this->t('Required'),
'$checks' => $this->installer->getChecks(), '$checks' => $this->installer->getChecks(),
'$pass' => $this->t('Site settings'), '$pass' => $this->t('Site settings'),
'$basepath' => $configCache->get('system', 'basepath'), '$basepath' => $this->configCache->get('system', 'basepath'),
'$system_url' => $configCache->get('system', 'url'), '$system_url' => $this->configCache->get('system', 'url'),
'$dbhost' => $configCache->get('database', 'hostname'), '$dbhost' => $this->configCache->get('database', 'hostname'),
'$dbuser' => $configCache->get('database', 'username'), '$dbuser' => $this->configCache->get('database', 'username'),
'$dbpass' => $configCache->get('database', 'password'), '$dbpass' => $this->configCache->get('database', 'password'),
'$dbdata' => $configCache->get('database', 'database'), '$dbdata' => $this->configCache->get('database', 'database'),
'$adminmail' => ['config-admin_email', '$adminmail' => ['config-admin_email',
$this->t('Site administrator email address'), $this->t('Site administrator email address'),
$configCache->get('config', 'admin_email'), $this->configCache->get('config', 'admin_email'),
$this->t('Your account email address must match this in order to use the web admin panel.'), $this->t('Your account email address must match this in order to use the web admin panel.'),
$this->t('Required'), 'autofocus', 'email'], $this->t('Required'), 'autofocus', 'email'],
'$timezone' => Temporal::getTimezoneField('system-default_timezone', '$timezone' => Temporal::getTimezoneField('system-default_timezone',
$this->t('Please select a default timezone for your website'), $this->t('Please select a default timezone for your website'),
$configCache->get('system', 'default_timezone'), $this->configCache->get('system', 'default_timezone'),
''), ''),
'$language' => ['system-language', '$language' => ['system-language',
$this->t('System Language:'), $this->t('System Language:'),
$configCache->get('system', 'language'), $this->configCache->get('system', 'language'),
$this->t('Set the default language for your Friendica installation interface and to send emails.'), $this->t('Set the default language for your Friendica installation interface and to send emails.'),
$lang_choices], $lang_choices],
'$php_path' => $configCache->get('config', 'php_path'), '$php_path' => $this->configCache->get('config', 'php_path'),
'$submit' => $this->t('Submit') '$submit' => $this->t('Submit')
]); ]);
break; break;