1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-08 15:57:01 +02:00

Update installer to exclude some $config settings when already supplied by site profile's config.php, so that it's not duplicating any settings when writing /site/config.php

This commit is contained in:
Ryan Cramer
2024-04-19 12:02:01 -04:00
parent 29ecddadeb
commit a37f237900

View File

@@ -871,6 +871,7 @@ class Installer {
$file = __FILE__; $file = __FILE__;
$time = time(); $time = time();
$host = empty($values['httpHosts']) ? '' : implode(',', $values['httpHosts']); $host = empty($values['httpHosts']) ? '' : implode(',', $values['httpHosts']);
$s = is_file("./site/config.php") ? file_get_contents("./site/config.php") : '';
if(function_exists('random_bytes')) { if(function_exists('random_bytes')) {
$authSalt = sha1(random_bytes(random_int(40, 128))); $authSalt = sha1(random_bytes(random_int(40, 128)));
@@ -904,7 +905,7 @@ class Installer {
$cfg .= "\n\$config->dbEngine = 'InnoDB';"; $cfg .= "\n\$config->dbEngine = 'InnoDB';";
} }
$cfg .= if(strpos($s, '$config->userAuthSalt') === false) $cfg .=
"\n" . "\n" .
"\n/**" . "\n/**" .
"\n * Installer: User Authentication Salt " . "\n * Installer: User Authentication Salt " .
@@ -915,7 +916,10 @@ class Installer {
"\n * Do not change this value, or user passwords will no longer work." . "\n * Do not change this value, or user passwords will no longer work." .
"\n * " . "\n * " .
"\n */" . "\n */" .
"\n\$config->userAuthSalt = '$authSalt'; " . "\n\$config->userAuthSalt = '$authSalt'; ";
if(strpos($s, '$config->tableSalt') === false) $cfg .=
$cfg .=
"\n" . "\n" .
"\n/**" . "\n/**" .
"\n * Installer: Table Salt (General Purpose) " . "\n * Installer: Table Salt (General Purpose) " .
@@ -925,7 +929,9 @@ class Installer {
"\n * this value or it may break internal system comparisons that use it. " . "\n * this value or it may break internal system comparisons that use it. " .
"\n * " . "\n * " .
"\n */" . "\n */" .
"\n\$config->tableSalt = '$tableSalt'; " . "\n\$config->tableSalt = '$tableSalt'; ";
$cfg .=
"\n" . "\n" .
"\n/**" . "\n/**" .
"\n * Installer: File Permission Configuration" . "\n * Installer: File Permission Configuration" .
@@ -939,13 +945,17 @@ class Installer {
"\n * " . "\n * " .
"\n */" . "\n */" .
"\n\$config->timezone = '$values[timezone]';" . "\n\$config->timezone = '$values[timezone]';" .
"\n" . "\n";
if(strpos($s, '$config->defaultAdminTheme') === false) $cfg .=
"\n/**" . "\n/**" .
"\n * Installer: Admin theme" . "\n * Installer: Admin theme" .
"\n * " . "\n * " .
"\n */" . "\n */" .
"\n\$config->defaultAdminTheme = 'AdminThemeUikit';" . "\n\$config->defaultAdminTheme = 'AdminThemeUikit';" .
"\n" . "\n";
if(strpos($s, '$config->installed ') === false) $cfg .=
"\n/**" . "\n/**" .
"\n * Installer: Unix timestamp of date/time installed" . "\n * Installer: Unix timestamp of date/time installed" .
"\n * " . "\n * " .
@@ -979,7 +989,6 @@ class Installer {
"\n\$config->debug = " . ($values['debugMode'] ? 'true;' : 'false;') . "\n\$config->debug = " . ($values['debugMode'] ? 'true;' : 'false;') .
"\n\n"; "\n\n";
$s = is_file("./site/config.php") ? file_get_contents("./site/config.php") : '';
if(strpos($s, '<' . '?php') === false) $cfg = '<' . "?php namespace ProcessWire;\n\n" . $cfg; if(strpos($s, '<' . '?php') === false) $cfg = '<' . "?php namespace ProcessWire;\n\n" . $cfg;
if(($fp = fopen("./site/config.php", "a")) && fwrite($fp, $cfg)) { if(($fp = fopen("./site/config.php", "a")) && fwrite($fp, $cfg)) {