Project

General

Profile

Actions

Bug #103826

closed

setup command with TYPO3_INSTALL_DB_* ENV vars does not work.

Added by Rafael Kähm about 2 months ago. Updated about 2 months ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
Install Tool
Target version:
Start date:
2024-05-13
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
13
PHP Version:
8.2
Tags:
Complexity:
no-brainer
Is Regression:
Sprint Focus:

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];
                }
            }
        }
Actions #1

Updated by Gerrit Code Review about 2 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

Actions #2

Updated by Gerrit Code Review about 2 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

Actions #3

Updated by Benni Mack about 2 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF