Skip to content

Commit d24e5f5

Browse files
fix: address review feedback for requirements check module
- Split DB version config into MariaDB/MySQL-specific thresholds - Strip export prefix in env file parser - Use exact in_array matching for locale checks - Check supplementary groups for user group validation - Update docs to reflect client-specific DB versions
1 parent 4ac8ecf commit d24e5f5

6 files changed

Lines changed: 27 additions & 12 deletions

File tree

deployer/requirements/config/set.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
]);
7979

8080
// Database
81-
set('requirements_db_min_version', '10.2.7');
81+
set('requirements_mariadb_min_version', '10.2.7');
82+
set('requirements_mysql_min_version', '8.0.0');
8283

8384
// User / permissions
8485
set('requirements_user_group', 'www-data');

deployer/requirements/functions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ function getSharedEnvVars(): array
176176
$value = substr($value, 1, -1);
177177
}
178178

179-
$vars[trim($parts[0])] = $value;
179+
$key = trim(preg_replace('/^export\s+/', '', trim($parts[0])));
180+
$vars[$key] = $value;
180181
}
181182

182183
return $vars;

deployer/requirements/task/check_database.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,21 @@
3535
return;
3636
}
3737

38-
$minVersion = get('requirements_db_min_version');
39-
40-
if (preg_match('/Distrib\s+([\d.]+)/', $versionOutput, $matches)
41-
|| preg_match('/Ver\s+([\d.]+)/', $versionOutput, $matches)) {
38+
if (preg_match('/Distrib\s+([\d.]+)/', $versionOutput, $matches)) {
39+
$actualVersion = $matches[1];
40+
$minVersion = get('requirements_mariadb_min_version');
41+
$meets = version_compare($actualVersion, $minVersion, '>=');
42+
$info = $meets ? "MariaDB $actualVersion" : "MariaDB $actualVersion (required: >= $minVersion)";
43+
addRequirementRow(
44+
'Database client',
45+
$meets ? REQUIREMENT_OK : REQUIREMENT_FAIL,
46+
$info
47+
);
48+
} elseif (preg_match('/Ver\s+([\d.]+)/', $versionOutput, $matches)) {
4249
$actualVersion = $matches[1];
50+
$minVersion = get('requirements_mysql_min_version');
4351
$meets = version_compare($actualVersion, $minVersion, '>=');
44-
$info = $meets ? $actualVersion : "$actualVersion (required: >= $minVersion)";
52+
$info = $meets ? "MySQL $actualVersion" : "MySQL $actualVersion (required: >= $minVersion)";
4553
addRequirementRow(
4654
'Database client',
4755
$meets ? REQUIREMENT_OK : REQUIREMENT_FAIL,

deployer/requirements/task/check_locales.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@
1919
return;
2020
}
2121

22+
$localeLines = array_map('trim', explode("\n", $availableLocales));
23+
2224
foreach (get('requirements_locales') as $locale) {
2325
$normalizedLocale = strtolower($locale);
2426
$altLocale = str_replace('.utf8', '.utf-8', $normalizedLocale);
2527

26-
if (str_contains($availableLocales, $normalizedLocale)
27-
|| str_contains($availableLocales, $altLocale)) {
28+
$found = in_array($normalizedLocale, $localeLines, true)
29+
|| in_array($altLocale, $localeLines, true);
30+
31+
if ($found) {
2832
addRequirementRow("Locale: $locale", REQUIREMENT_OK, 'Available');
2933
} else {
3034
addRequirementRow("Locale: $locale", REQUIREMENT_FAIL, 'Not available');

deployer/requirements/task/check_user.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
$expectedGroup = get('requirements_user_group');
1515

16-
// Check primary group
16+
// Check group membership (primary + supplementary)
1717
try {
18+
$groups = explode(' ', trim(run('id -Gn')));
19+
$meets = in_array($expectedGroup, $groups, true);
1820
$actualGroup = trim(run('id -gn'));
19-
$meets = ($actualGroup === $expectedGroup);
2021
addRequirementRow(
2122
'User group',
2223
$meets ? REQUIREMENT_OK : REQUIREMENT_WARN,

docs/REQUIREMENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Checks PHP CLI configuration values against expected minimums:
4242

4343
### Database client
4444

45-
Checks for the availability of the `mariadb` or `mysql` client and validates the version against the configured minimum (default: >= 10.2.7).
45+
Checks for the availability of the `mariadb` or `mysql` client and validates the version against client-specific minimums (MariaDB: >= 10.2.7, MySQL: >= 8.0.0).
4646

4747
### User and permissions
4848

0 commit comments

Comments
 (0)