diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2022-11-07 18:30:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-07 18:30:10 +0300 |
commit | 64a79bc93f5165271c1304a6370cbbc30b32360f (patch) | |
tree | e1d5c7535beb026842e9d54662a3f1c8113ed298 | |
parent | 644ef1a86c842a9968b0ed4b8e0e493dbce86421 (diff) | |
parent | 3d66523497e21a0dfde04af7ce1748e02519d4be (diff) |
Merge pull request #8283 from nextcloud/bugfix/8269/make-apachectl-check-less-error-prone
Make apache configuration check less error prone
-rw-r--r-- | lib/Settings/Admin/AdminSettings.php | 20 | ||||
-rw-r--r-- | src/components/AdminSettings/WebServerSetupChecks.vue | 12 |
2 files changed, 23 insertions, 9 deletions
diff --git a/lib/Settings/Admin/AdminSettings.php b/lib/Settings/Admin/AdminSettings.php index 29f5f9671..e107ed348 100644 --- a/lib/Settings/Admin/AdminSettings.php +++ b/lib/Settings/Admin/AdminSettings.php @@ -101,7 +101,7 @@ class AdminSettings implements ISettings { $this->initialState->provideInitialState('default_group_notification', (int) $this->serverConfig->getAppValue('spreed', 'default_group_notification', Participant::NOTIFY_MENTION)); $this->initialState->provideInitialState('conversations_files', (int) $this->serverConfig->getAppValue('spreed', 'conversations_files', '1')); $this->initialState->provideInitialState('conversations_files_public_shares', (int) $this->serverConfig->getAppValue('spreed', 'conversations_files_public_shares', '1')); - $this->initialState->provideInitialState('valid_apache_php_configuration', (int) $this->validApachePHPConfiguration()); + $this->initialState->provideInitialState('valid_apache_php_configuration', $this->validApachePHPConfiguration()); } protected function initAllowedGroups(): void { @@ -502,12 +502,20 @@ class AdminSettings implements ISettings { return $groups; } - protected function validApachePHPConfiguration(): bool { + protected function validApachePHPConfiguration(): string { + if (!function_exists('exec')) { + return 'unknown'; + } + $output = []; - @exec('apachectl -M | grep mpm', $output, $returnCode); + try { + @exec('apachectl -M | grep mpm', $output, $returnCode); + } catch (\Throwable $e) { + return 'unknown'; + } if ($returnCode > 0) { - return true; + return 'unknown'; } $apacheModule = implode("\n", $output); @@ -515,11 +523,11 @@ class AdminSettings implements ISettings { if ($usingFPM) { // Needs to use mpm_event - return strpos($apacheModule, 'mpm_event') !== false; + return strpos($apacheModule, 'mpm_event') !== false ? '' : 'invalid'; } // Needs to use mpm_prefork - return strpos($apacheModule, 'mpm_prefork') !== false; + return strpos($apacheModule, 'mpm_prefork') !== false ? '' : 'invalid'; } /** diff --git a/src/components/AdminSettings/WebServerSetupChecks.vue b/src/components/AdminSettings/WebServerSetupChecks.vue index 79f860c46..075e507a7 100644 --- a/src/components/AdminSettings/WebServerSetupChecks.vue +++ b/src/components/AdminSettings/WebServerSetupChecks.vue @@ -77,7 +77,7 @@ export default { data() { return { backgroundBlurLoaded: undefined, - validApachePHPConfiguration: true, + validApachePHPConfiguration: '', } }, @@ -115,12 +115,18 @@ export default { }, apacheWarning() { - return t('spreed', 'It seems that the PHP and Apache configuration is not compatible. Please note that PHP can only be used with the MPM_PREFORK module and PHP-FPM can only be used with the MPM_EVENT module.') + if (this.validApachePHPConfiguration === 'invalid') { + return t('spreed', 'It seems that the PHP and Apache configuration is not compatible. Please note that PHP can only be used with the MPM_PREFORK module and PHP-FPM can only be used with the MPM_EVENT module.') + } + if (this.validApachePHPConfiguration === 'unknown') { + return t('spreed', 'Could not detect the PHP and Apache configuration because exec is disabled or apachectl is not working as expected. Please note that PHP can only be used with the MPM_PREFORK module and PHP-FPM can only be used with the MPM_EVENT module.') + } + return '' }, }, mounted() { - this.validApachePHPConfiguration = parseInt(loadState('spreed', 'valid_apache_php_configuration')) === 1 + this.validApachePHPConfiguration = loadState('spreed', 'valid_apache_php_configuration') }, beforeMount() { |