Commit 7b665c58 authored by Helmut Hummel's avatar Helmut Hummel Committed by Jigal van Hemert
Browse files

[BUGFIX] Harden database select step

Currently this step does not do precautions, when
the selected database does not exist. Additionally the step
silently skips when the chosen database already has tables.

Although the UI currently does not allow to select a non
empty database, there are situations imaginable, where the database
is empty during generation of the input form but is filled directly after that,
or a database was empty but then got deleted,
which previously ended up with a fatal error.

This change now takes care of both cases and outputs a nice error message accordingly.

Resolves: #75964
Releases: 7.6, master
Change-Id: Ibc7083aa120f420d6201e512f3f41699f55c5f7f

Reviewed-by: Wouter Wolters's avatarWouter Wolters <>
Reviewed-by: Markus Klein's avatarMarkus Klein <>
Reviewed-by: default avatarDaniel Goerz <>
Tested-by: default avatarDaniel Goerz <>
Reviewed-by: Jigal van Hemert's avatarJigal van Hemert <>
Tested-by: Jigal van Hemert's avatarJigal van Hemert <>
parent 3db4a3e8
......@@ -74,10 +74,29 @@ class DatabaseSelect extends AbstractStepAction
} elseif ($postValues['type'] === 'existing' && !empty($postValues['existing'])) {
// Only store database information when it's empty
$existingTables = $this->databaseConnection->admin_get_tables();
try {
$existingTables = $this->databaseConnection->admin_get_tables();
if (!empty($existingTables)) {
$errorStatus = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Status\ErrorStatus::class);
$errorStatus->setTitle('Selected database is not empty!');
sprintf('Cannot use database "%s"', $postValues['existing'])
. ', because it has tables already. Please select a different database or choose to create one!'
$result[] = $errorStatus;
} catch (\RuntimeException $e) {
$errorStatus = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Status\ErrorStatus::class);
$errorStatus->setTitle('Could not connect to selected database!');
sprintf('Could not connect to database "%s"', $postValues['existing'])
. '! Make sure it really exists and your database user has the permissions to select it!'
$result[] = $errorStatus;
$isInitialInstallation = $configurationManager->getConfigurationValueByPath('SYS/isInitialInstallationInProgress');
if (!$isInitialInstallation || empty($existingTables)) {
if (!$isInitialInstallation || empty($result)) {
$localConfigurationPathValuePairs['DB/Connections/Default/dbname'] = $postValues['existing'];
// check if database charset is utf-8
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment