From 8e2e341532c78a2c91dd8918b8d9f624be79c787 Mon Sep 17 00:00:00 2001 From: Konrad Michalik Date: Thu, 19 Feb 2026 14:29:11 +0100 Subject: [PATCH 1/3] fix: support remote database hosts in health check --- deployer/requirements/task/health.php | 61 ++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 10 deletions(-) diff --git a/deployer/requirements/task/health.php b/deployer/requirements/task/health.php index ba002b9..f88a533 100644 --- a/deployer/requirements/task/health.php +++ b/deployer/requirements/task/health.php @@ -45,23 +45,64 @@ $db = detectDatabaseProduct(); $dbLabel = $db !== null ? $db['label'] : 'Database'; $adminCmd = ($db !== null && $db['product'] === 'mariadb') ? 'mariadb-admin' : 'mysqladmin'; + $dbCredentials = resolveDatabaseCredentials(); $dbChecked = false; - try { - run("$adminCmd ping --silent 2>/dev/null"); - addRequirementRow('Database server', REQUIREMENT_OK, "$dbLabel responding"); - $dbChecked = true; - } catch (RunException) { - // Admin tool not available — fall through to process check + // Try mysqladmin ping with credentials when available + if ($dbCredentials !== null) { + $pingCmd = sprintf( + '%s ping --silent -h %s -P %d -u %s --password=%s 2>/dev/null', + $adminCmd, + escapeshellarg($dbCredentials['host']), + $dbCredentials['port'], + escapeshellarg($dbCredentials['user']), + escapeshellarg($dbCredentials['password']) + ); + + try { + run($pingCmd); + $hostInfo = $dbCredentials['host'] === '127.0.0.1' || $dbCredentials['host'] === 'localhost' + ? 'local' + : $dbCredentials['host']; + addRequirementRow('Database server', REQUIREMENT_OK, "$dbLabel responding ($hostInfo)"); + $dbChecked = true; + } catch (RunException) { + // Credentials available but ping failed — fall through + } } + // Fallback: try mysqladmin ping without credentials (uses ~/.my.cnf or socket) if (!$dbChecked) { - $dbProcess = isServiceActive('mysqld', 'mariadbd'); + try { + run("$adminCmd ping --silent 2>/dev/null"); + addRequirementRow('Database server', REQUIREMENT_OK, "$dbLabel responding"); + $dbChecked = true; + } catch (RunException) { + // Admin tool not available — fall through to process check + } + } - if ($dbProcess !== null) { - addRequirementRow('Database server', REQUIREMENT_OK, "$dbLabel process running ($dbProcess)"); + // Only check for local processes if the database host is local (or unknown) + if (!$dbChecked) { + $isRemoteDb = $dbCredentials !== null + && $dbCredentials['host'] !== '127.0.0.1' + && $dbCredentials['host'] !== 'localhost'; + + if ($isRemoteDb) { + addRequirementRow('Database server', REQUIREMENT_FAIL, sprintf( + 'Cannot reach %s on %s:%d', + $dbLabel, + $dbCredentials['host'], + $dbCredentials['port'] + )); } else { - addRequirementRow('Database server', REQUIREMENT_FAIL, 'No mysqld or mariadbd process found'); + $dbProcess = isServiceActive('mysqld', 'mariadbd'); + + if ($dbProcess !== null) { + addRequirementRow('Database server', REQUIREMENT_OK, "$dbLabel process running ($dbProcess)"); + } else { + addRequirementRow('Database server', REQUIREMENT_FAIL, 'No mysqld or mariadbd process found'); + } } } From 6e5e0da8c093eda68fc0dfde0b81f95f4f0801c2 Mon Sep 17 00:00:00 2001 From: Konrad Michalik Date: Thu, 19 Feb 2026 14:29:15 +0100 Subject: [PATCH 2/3] docs: update standalone tasks links in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 180a215..ab74ea4 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,10 @@ Read the [documentation](docs/TYPO3.md) for detailed installation instructions a ### Standalone Tasks - [MS Teams Notification](deployer/notification/task/ms_teams.php) - [Database backup](deployer/sync/task/database_backup.php) -- [Database management](docs/DATABASE.md) - [Security check](docs/SECURITY.md) - [Development](docs/DEV.md) - [Debug helper](docs/DEBUG.md) +- [Requirements](docs/REQUIREMENTS.md) ## 💛 Acknowledgements From 9732fa722e116ff85e0e6c5993d165e55221bf92 Mon Sep 17 00:00:00 2001 From: Konrad Michalik Date: Thu, 19 Feb 2026 15:10:34 +0100 Subject: [PATCH 3/3] fix: skip local socket fallback when database host is remote --- deployer/requirements/task/health.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/deployer/requirements/task/health.php b/deployer/requirements/task/health.php index f88a533..0e93d9e 100644 --- a/deployer/requirements/task/health.php +++ b/deployer/requirements/task/health.php @@ -71,8 +71,13 @@ } } + $isRemoteDb = $dbCredentials !== null + && $dbCredentials['host'] !== '127.0.0.1' + && $dbCredentials['host'] !== 'localhost'; + // Fallback: try mysqladmin ping without credentials (uses ~/.my.cnf or socket) - if (!$dbChecked) { + // Skip for remote hosts — a local socket hit would be a false positive. + if (!$dbChecked && !$isRemoteDb) { try { run("$adminCmd ping --silent 2>/dev/null"); addRequirementRow('Database server', REQUIREMENT_OK, "$dbLabel responding"); @@ -84,10 +89,6 @@ // Only check for local processes if the database host is local (or unknown) if (!$dbChecked) { - $isRemoteDb = $dbCredentials !== null - && $dbCredentials['host'] !== '127.0.0.1' - && $dbCredentials['host'] !== 'localhost'; - if ($isRemoteDb) { addRequirementRow('Database server', REQUIREMENT_FAIL, sprintf( 'Cannot reach %s on %s:%d',