@@ -14,89 +14,89 @@ |
||
14 | 14 | use OCP\SetupCheck\SetupResult; |
15 | 15 | |
16 | 16 | class PhpModules implements ISetupCheck { |
17 | - protected const REQUIRED_MODULES = [ |
|
18 | - 'ctype', |
|
19 | - 'curl', |
|
20 | - 'dom', |
|
21 | - 'fileinfo', |
|
22 | - 'gd', |
|
23 | - 'mbstring', |
|
24 | - 'openssl', |
|
25 | - 'posix', |
|
26 | - 'session', |
|
27 | - 'xml', |
|
28 | - 'xmlreader', |
|
29 | - 'xmlwriter', |
|
30 | - 'zip', |
|
31 | - 'zlib', |
|
32 | - ]; |
|
33 | - protected const RECOMMENDED_MODULES = [ |
|
34 | - 'exif', |
|
35 | - 'gmp', |
|
36 | - 'intl', |
|
37 | - 'sodium', |
|
38 | - 'sysvsem', |
|
39 | - ]; |
|
17 | + protected const REQUIRED_MODULES = [ |
|
18 | + 'ctype', |
|
19 | + 'curl', |
|
20 | + 'dom', |
|
21 | + 'fileinfo', |
|
22 | + 'gd', |
|
23 | + 'mbstring', |
|
24 | + 'openssl', |
|
25 | + 'posix', |
|
26 | + 'session', |
|
27 | + 'xml', |
|
28 | + 'xmlreader', |
|
29 | + 'xmlwriter', |
|
30 | + 'zip', |
|
31 | + 'zlib', |
|
32 | + ]; |
|
33 | + protected const RECOMMENDED_MODULES = [ |
|
34 | + 'exif', |
|
35 | + 'gmp', |
|
36 | + 'intl', |
|
37 | + 'sodium', |
|
38 | + 'sysvsem', |
|
39 | + ]; |
|
40 | 40 | |
41 | - public function __construct( |
|
42 | - private IL10N $l10n, |
|
43 | - private IURLGenerator $urlGenerator, |
|
44 | - ) { |
|
45 | - } |
|
41 | + public function __construct( |
|
42 | + private IL10N $l10n, |
|
43 | + private IURLGenerator $urlGenerator, |
|
44 | + ) { |
|
45 | + } |
|
46 | 46 | |
47 | - public function getName(): string { |
|
48 | - return $this->l10n->t('PHP modules'); |
|
49 | - } |
|
47 | + public function getName(): string { |
|
48 | + return $this->l10n->t('PHP modules'); |
|
49 | + } |
|
50 | 50 | |
51 | - public function getCategory(): string { |
|
52 | - return 'php'; |
|
53 | - } |
|
51 | + public function getCategory(): string { |
|
52 | + return 'php'; |
|
53 | + } |
|
54 | 54 | |
55 | - protected function getRecommendedModuleDescription(string $module): string { |
|
56 | - return match($module) { |
|
57 | - 'intl' => $this->l10n->t('increases language translation performance and fixes sorting of non-ASCII characters'), |
|
58 | - 'sodium' => $this->l10n->t('for Argon2 for password hashing'), |
|
59 | - 'gmp' => $this->l10n->t('required for SFTP storage and recommended for WebAuthn performance'), |
|
60 | - 'exif' => $this->l10n->t('for picture rotation in server and metadata extraction in the Photos app'), |
|
61 | - default => '', |
|
62 | - }; |
|
63 | - } |
|
55 | + protected function getRecommendedModuleDescription(string $module): string { |
|
56 | + return match($module) { |
|
57 | + 'intl' => $this->l10n->t('increases language translation performance and fixes sorting of non-ASCII characters'), |
|
58 | + 'sodium' => $this->l10n->t('for Argon2 for password hashing'), |
|
59 | + 'gmp' => $this->l10n->t('required for SFTP storage and recommended for WebAuthn performance'), |
|
60 | + 'exif' => $this->l10n->t('for picture rotation in server and metadata extraction in the Photos app'), |
|
61 | + default => '', |
|
62 | + }; |
|
63 | + } |
|
64 | 64 | |
65 | - public function run(): SetupResult { |
|
66 | - $missingRecommendedModules = $this->getMissingModules(self::RECOMMENDED_MODULES); |
|
67 | - $missingRequiredModules = $this->getMissingModules(self::REQUIRED_MODULES); |
|
68 | - if (!empty($missingRequiredModules)) { |
|
69 | - return SetupResult::error( |
|
70 | - $this->l10n->t('This instance is missing some required PHP modules. It is required to install them: %s.', implode(', ', $missingRequiredModules)), |
|
71 | - $this->urlGenerator->linkToDocs('admin-php-modules') |
|
72 | - ); |
|
73 | - } elseif (!empty($missingRecommendedModules)) { |
|
74 | - $moduleList = implode( |
|
75 | - "\n", |
|
76 | - array_map( |
|
77 | - fn (string $module) => '- ' . $module . ' ' . $this->getRecommendedModuleDescription($module), |
|
78 | - $missingRecommendedModules |
|
79 | - ) |
|
80 | - ); |
|
81 | - return SetupResult::info( |
|
82 | - $this->l10n->t("This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them:\n%s", $moduleList), |
|
83 | - $this->urlGenerator->linkToDocs('admin-php-modules') |
|
84 | - ); |
|
85 | - } else { |
|
86 | - return SetupResult::success(); |
|
87 | - } |
|
88 | - } |
|
65 | + public function run(): SetupResult { |
|
66 | + $missingRecommendedModules = $this->getMissingModules(self::RECOMMENDED_MODULES); |
|
67 | + $missingRequiredModules = $this->getMissingModules(self::REQUIRED_MODULES); |
|
68 | + if (!empty($missingRequiredModules)) { |
|
69 | + return SetupResult::error( |
|
70 | + $this->l10n->t('This instance is missing some required PHP modules. It is required to install them: %s.', implode(', ', $missingRequiredModules)), |
|
71 | + $this->urlGenerator->linkToDocs('admin-php-modules') |
|
72 | + ); |
|
73 | + } elseif (!empty($missingRecommendedModules)) { |
|
74 | + $moduleList = implode( |
|
75 | + "\n", |
|
76 | + array_map( |
|
77 | + fn (string $module) => '- ' . $module . ' ' . $this->getRecommendedModuleDescription($module), |
|
78 | + $missingRecommendedModules |
|
79 | + ) |
|
80 | + ); |
|
81 | + return SetupResult::info( |
|
82 | + $this->l10n->t("This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them:\n%s", $moduleList), |
|
83 | + $this->urlGenerator->linkToDocs('admin-php-modules') |
|
84 | + ); |
|
85 | + } else { |
|
86 | + return SetupResult::success(); |
|
87 | + } |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Checks for potential PHP modules that would improve the instance |
|
92 | - * |
|
93 | - * @param string[] $modules modules to test |
|
94 | - * @return string[] A list of PHP modules which are missing |
|
95 | - */ |
|
96 | - protected function getMissingModules(array $modules): array { |
|
97 | - return array_values(array_filter( |
|
98 | - $modules, |
|
99 | - fn (string $module) => !extension_loaded($module), |
|
100 | - )); |
|
101 | - } |
|
90 | + /** |
|
91 | + * Checks for potential PHP modules that would improve the instance |
|
92 | + * |
|
93 | + * @param string[] $modules modules to test |
|
94 | + * @return string[] A list of PHP modules which are missing |
|
95 | + */ |
|
96 | + protected function getMissingModules(array $modules): array { |
|
97 | + return array_values(array_filter( |
|
98 | + $modules, |
|
99 | + fn (string $module) => !extension_loaded($module), |
|
100 | + )); |
|
101 | + } |
|
102 | 102 | } |