-
-
-
-
-
- After clicking the "Submit" button, all necessary tables will be created and filled with your data.
- Depending on your system, this may take some time. Stay tuned.
-
+
+
+
+
+ After clicking the "Submit" button, all necessary tables will be created and filled with your data.
+ Depending on your system, this may take some time. Stay tuned.
+
+
-
-
-
-
+
+
+
{% endif %}
diff --git a/phpmyfaq/src/phpMyFAQ/Controller/Frontend/SetupController.php b/phpmyfaq/src/phpMyFAQ/Controller/Frontend/SetupController.php
index 67aacaf51f..65fad84e55 100644
--- a/phpmyfaq/src/phpMyFAQ/Controller/Frontend/SetupController.php
+++ b/phpmyfaq/src/phpMyFAQ/Controller/Frontend/SetupController.php
@@ -61,6 +61,7 @@ public function index(): Response
'documentationUrl' => System::getDocumentationUrl(),
'checkBasicError' => $checkBasicError,
'nonCriticalSettings' => $installer->checkNoncriticalSettings(),
+ 'filePermissions' => $installer->checkFilesystemPermissions(),
'supportedDatabases' => $system->getSupportedSafeDatabases(),
'currentPath' => dirname(__DIR__, 4),
'isLdapEnabled' => $installer->hasLdapSupport(),
diff --git a/phpmyfaq/src/phpMyFAQ/Setup/Installer.php b/phpmyfaq/src/phpMyFAQ/Setup/Installer.php
index dd3396b496..da7c56bdc2 100644
--- a/phpmyfaq/src/phpMyFAQ/Setup/Installer.php
+++ b/phpmyfaq/src/phpMyFAQ/Setup/Installer.php
@@ -429,6 +429,10 @@ class Installer extends Setup
'layout.customCss' => '',
];
+ /**
+ * Array with form inputs
+ * @var array
+ */
public array $formInputs = [
// Ask Question inputs
[
@@ -574,7 +578,7 @@ class Installer extends Setup
*
* @throws \Exception
*/
- public function __construct(protected System $system)
+ public function __construct(private System $system)
{
parent::__construct();
@@ -592,8 +596,6 @@ public function __construct(protected System $system)
/**
* Removes the database.php and the ldap.php if an installation failed.
- *
- * @todo have to be moved to the Installer class
*/
public static function cleanFailedInstallationFiles(): void
{
@@ -609,27 +611,21 @@ public static function cleanFailedInstallationFiles(): void
}
/**
- * Check absolutely necessary stuff and die.
+ * Check the necessary stuff and throw an exception if something is wrong.
* @throws Exception
*/
public function checkBasicStuff(): void
{
if (!$this->checkMinimumPhpVersion()) {
- throw new Exception(
- sprintf('Sorry, but you need PHP %s or later!', System::VERSION_MINIMUM_PHP)
- );
+ throw new Exception(sprintf('Sorry, but you need PHP %s or later!', System::VERSION_MINIMUM_PHP));
}
if (!function_exists('date_default_timezone_set')) {
- throw new Exception(
- 'Sorry, but setting a default timezone does not work in your environment!'
- );
+ throw new Exception('Sorry, but setting a default timezone does not work in your environment!');
}
if (!$this->system->checkDatabase()) {
- throw new Exception(
- 'No supported database detected!'
- );
+ throw new Exception('No supported database detected!');
}
if (!$this->system->checkRequiredExtensions()) {
@@ -642,55 +638,14 @@ public function checkBasicStuff(): void
}
if (!$this->system->checkInstallation()) {
- throw new Exception(
- 'phpMyFAQ is already installed! Please use the update.'
- );
- }
- }
-
- /**
- * Checks for the minimum PHP requirement and if the database credentials file is readable.
- *
- * @throws Exception
- * @todo this method should be in the the Update class
- */
- public function checkPreUpgrade(string $databaseType): void
- {
- $database = null;
- if (!$this->checkMinimumPhpVersion()) {
- throw new Exception(sprintf('Sorry, but you need PHP %s or later!', System::VERSION_MINIMUM_PHP));
- }
-
- if (!is_readable(PMF_ROOT_DIR . '/content/core/config/database.php')) {
- throw new Exception(
- 'It seems you never run a version of phpMyFAQ. Please use the installation script'
- );
- }
-
- if ('' !== $databaseType) {
- $databaseFound = false;
- foreach (array_keys($this->system->getSupportedDatabases()) as $database) {
- if ($database === $databaseType) {
- $databaseFound = true;
- break;
- }
- }
-
- if (!$databaseFound) {
- throw new Exception(
- sprintf(
- 'It seems you are using an unsupported database version. We found %s',
- ucfirst((string) $database)
- )
- );
- }
+ throw new Exception('phpMyFAQ is already installed! Please use the update.');
}
}
/**
* Checks if the file permissions are okay.
*/
- public function checkFilesystemPermissions(): void
+ public function checkFilesystemPermissions(): string|null
{
$instanceSetup = new Setup();
$instanceSetup->setRootDir(PMF_ROOT_DIR);
@@ -705,22 +660,27 @@ public function checkFilesystemPermissions(): void
$failedDirs = $instanceSetup->checkDirs($dirs);
$numDirs = count($failedDirs);
+ $hints = '';
if (1 <= $numDirs) {
- printf(
+ $hints .= sprintf(
'The following %s could not be created or %s not writable:
',
(1 < $numDirs) ? 'directories' : 'directory',
(1 < $numDirs) ? 'are' : 'is'
);
foreach ($failedDirs as $failedDir) {
- echo "- {$failedDir}
\n";
+ $hints .= "- {$failedDir}
\n";
}
- printf(
+ $hints .= sprintf(
'
Please create %s manually and/or change access to chmod 775 (or ' .
'greater if necessary).
',
(1 < $numDirs) ? 'them' : 'it'
);
+
+ return $hints;
}
+
+ return null;
}
/**
@@ -872,8 +832,6 @@ public function startInstall(array|null $setup = null): void
//
$ldapEnabled = Filter::filterInput(INPUT_POST, 'ldap_enabled', FILTER_SANITIZE_SPECIAL_CHARS);
if (extension_loaded('ldap') && !is_null($ldapEnabled)) {
- $ldapSetup = [];
-
// check LDAP entries
$ldapSetup['ldapServer'] = Filter::filterInput(INPUT_POST, 'ldap_server', FILTER_SANITIZE_SPECIAL_CHARS);
if (is_null($ldapSetup['ldapServer'])) {
@@ -965,7 +923,7 @@ public function startInstall(array|null $setup = null): void
$esSetup = [];
}
- // check login name
+ // check the login name
if (!isset($setup['loginname'])) {
$loginName = Filter::filterInput(INPUT_POST, 'loginname', FILTER_SANITIZE_SPECIAL_CHARS);
} else {