Bug #103826
closedsetup command with TYPO3_INSTALL_DB_* ENV vars does not work.
100%
Description
There is a trouble within \TYPO3\CMS\Install\Service\SetupDatabaseService::getDatabaseConfigurationFromEnvironment()
method.
The port is not casted to int after fetching it from ENV. See: https://github.com/TYPO3/typo3/blob/90e286e56eb55a1e0f5888b0f8f65917d97eedf4/typo3/sysext/install/Classes/Service/SetupDatabaseService.php#L220
Exception:
Uncaught TYPO3 Exception mysqli::real_connect(): Argument #5 ($port) must be of type ?int, string given thrown in file /var/www/html/vendor/doctrine/dbal/src/Driver/Mysqli/Driver.php in line 44
How to reproduce:¶
Try to run typo3 setup
command with defined TYPO3_INSTALL_DB_*
variables.
Proposed fix:¶
public function getDatabaseConfigurationFromEnvironment(): array
{
/** @var Params $envCredentials */
$envCredentials = [];
foreach (['driver', 'host', 'user', 'password', 'port', 'dbname', 'unix_socket'] as $value) {
$envVar = 'TYPO3_INSTALL_DB_' . strtoupper($value);
if (getenv($envVar) !== false) {
$envCredentials[$value] = getenv($envVar);
if($value === 'port') {
$envCredentials[$value] = (int)$envCredentials[$value];
}
}
}
Updated by Gerrit Code Review 6 months ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84231
Updated by Gerrit Code Review 6 months ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/84204
Updated by Benni Mack 6 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 79b8e1a1b690f0bfb44599388ba95b72d8236205.