Skip to content

Commit 78fb032

Browse files
fix: parse only the last output line when detecting MySQL datadir
1 parent 91fd529 commit 78fb032

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

deployer/requirements/task/check_disk_space.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ function detectDatabaseDatadir(array $credentials): ?string
5656
return null;
5757
}
5858

59-
// Output format: "datadir\t/var/lib/mysql/"
60-
$columns = preg_split('/\s+/', $output);
61-
$path = is_array($columns) ? ($columns[1] ?? null) : null;
59+
// Output format: "datadir\t/var/lib/mysql/", possibly preceded by mysql client warning lines
60+
// on stderr (merged into stdout by runMysqlQuery()), so only the last line is relevant.
61+
$lines = explode("\n", $output);
62+
$columns = explode("\t", trim((string) end($lines)));
63+
$path = $columns[1] ?? null;
6264

6365
return ('' !== $path && null !== $path) ? $path : null;
6466
}

0 commit comments

Comments
 (0)