Skip to content

Commit

Permalink
[TASK] Show not empty databases in install tool
Browse files Browse the repository at this point in the history
This patch enables the visibility of all databases the user has access
to but disables the non empty ones from being chosen.

Resolves: #52585
Releases: 6.2
Change-Id: Ic8b527c5d256e46b99f79c35d236809ce015cbef
Reviewed-on: https://review.typo3.org/24668
Reviewed-by: Nicole Cordes
Tested-by: Nicole Cordes
Reviewed-by: Thorsten Kahler
Tested-by: Thorsten Kahler
Reviewed-by: Alexander Opitz
Tested-by: Alexander Opitz
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
  • Loading branch information
IchHabRecht authored and neufeind committed Oct 15, 2013
1 parent 9044272 commit ced1f40
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public function execute() {
$this->initializeDatabaseConnection();
$postValues = $this->postValues['values'];
$localConfigurationPathValuePairs = array();
/** @var $configurationManager \TYPO3\CMS\Core\Configuration\ConfigurationManager */
$configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
if ($postValues['type'] === 'new') {
$newDatabaseName = $postValues['new'];
if (strlen($newDatabaseName) <= 50) {
Expand All @@ -74,12 +76,17 @@ public function execute() {
$result[] = $errorStatus;
}
} elseif ($postValues['type'] === 'existing') {
$localConfigurationPathValuePairs['DB/database'] = $postValues['existing'];
// Only store database information when it's empty
$this->databaseConnection->setDatabaseName($postValues['existing']);
$this->databaseConnection->sql_select_db();
$existingTables = $this->databaseConnection->admin_get_tables();
$isInitialInstallation = $configurationManager->getConfigurationValueByPath('SYS/isInitialInstallationInProgress');
if (!$isInitialInstallation || count($existingTables) === 0) {
$localConfigurationPathValuePairs['DB/database'] = $postValues['existing'];
}
}

if (!empty($localConfigurationPathValuePairs)) {
/** @var $configurationManager \TYPO3\CMS\Core\Configuration\ConfigurationManager */
$configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
$configurationManager->setLocalConfigurationValuesByPathValuePairs($localConfigurationPathValuePairs);
}

Expand Down Expand Up @@ -140,17 +147,18 @@ protected function getDatabaseList($initialInstallation) {
if ($initialInstallation === FALSE) {
return $allPossibleDatabases;
} else {
// In first installation we only show empty databases (no tables)
$databasesWithoutTables = array();
// In first installation we show all databases but disable not empty ones (with tables)
$databases = array();
foreach ($allPossibleDatabases as $database) {
$this->databaseConnection->setDatabaseName($database);
$this->databaseConnection->sql_select_db();
$existingTables = $this->databaseConnection->admin_get_tables();
if (count($existingTables) === 0) {
$databasesWithoutTables[] = $database;
}
$databases[] = array(
'name' => $database,
'tables' => count($existingTables),
);
}
return $databasesWithoutTables;
return $databases;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ <h3>Select database</h3>
onfocus="document.getElementById('t3-install-form-db-select-type-existing').checked=true;"
>
<option value="">Select database</option>
<f:for each="{databaseList}" as="database" iteration="databaseIterator">
<option value="{database}"{f:if(condition: databaseIterator.isFirst ,then: ' selected="selected"')}>{database}</option>
<f:for each="{databaseList}" as="database">
<f:if condition="{database.tables}">
<f:then>
<option value="{database.name}" disabled="disabled">{database.name} ({database.tables} Tables)</option>
</f:then>
<f:else>
<option value="{database.name}">{database.name}</option>
</f:else>
</f:if>
</f:for>
</select>
</div>
Expand Down

0 comments on commit ced1f40

Please sign in to comment.