Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions extra/examples/wsc-dev-config-55.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"auto": true,
"host": "localhost",
"password": "root",
"username": "root",
"dbNumber": "2"
"username": "root"
},
"useDefaultInstallPath": true,
"forceStaticCookiePrefix": true
Expand Down
19 changes: 3 additions & 16 deletions wcfsetup/install/files/lib/system/WCFSetup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,15 +651,13 @@ protected function configureDB()
$dbUser = $_ENV['WCFSETUP_DBUSER'];
$dbPassword = $_ENV['WCFSETUP_DBPASSWORD'];
$dbName = $_ENV['WCFSETUP_DBNAME'];
$dbNumber = 1;

$attemptConnection = true;
} elseif (self::$developerMode && ($config = DevtoolsSetup::getInstance()->getDatabaseConfig()) !== null) {
$dbHost = $config['host'];
$dbUser = $config['username'];
$dbPassword = $config['password'];
$dbName = $config['dbName'];
$dbNumber = $config['dbNumber'];

if ($config['auto']) {
$attemptConnection = true;
Expand All @@ -669,7 +667,6 @@ protected function configureDB()
$dbUser = 'root';
$dbPassword = '';
$dbName = 'wcf';
$dbNumber = 1;
}

if ($attemptConnection) {
Expand All @@ -686,11 +683,6 @@ protected function configureDB()
$dbName = $_POST['dbName'];
}

// ensure that $dbNumber is zero or a positive integer
if (isset($_POST['dbNumber'])) {
$dbNumber = \max(0, \intval($_POST['dbNumber']));
}

// get port
$dbHostWithoutPort = $dbHost;
$dbPort = 0;
Expand Down Expand Up @@ -790,7 +782,7 @@ protected function configureDB()
*/

// check for table conflicts
$conflictedTables = $this->getConflictedTables($db, $dbNumber);
$conflictedTables = $this->getConflictedTables($db);

// write config.inc
if (empty($conflictedTables)) {
Expand All @@ -803,7 +795,7 @@ protected function configureDB()
$file->write("\$dbUser = '" . \str_replace("'", "\\'", $dbUser) . "';\n");
$file->write("\$dbPassword = '" . \str_replace("'", "\\'", $dbPassword) . "';\n");
$file->write("\$dbName = '" . \str_replace("'", "\\'", $dbName) . "';\n");
$file->write("if (!defined('WCF_N')) define('WCF_N', {$dbNumber});\n");
$file->write("if (!defined('WCF_N')) define('WCF_N', 1);\n");
$file->close();

// go to next step
Expand All @@ -823,7 +815,6 @@ protected function configureDB()
'dbUser' => $dbUser,
'dbPassword' => $dbPassword,
'dbName' => $dbName,
'dbNumber' => $dbNumber,
'nextStep' => 'configureDB',
]);
WCF::getTPL()->display('stepConfigureDB');
Expand All @@ -834,17 +825,13 @@ protected function configureDB()
* which will be created in the next step.
*
* @param \wcf\system\database\Database $db
* @param int $dbNumber
* @return string[] list of already existing tables
*/
protected function getConflictedTables($db, $dbNumber)
protected function getConflictedTables($db)
{
// get content of the sql structure file
$sql = \file_get_contents(TMP_DIR . 'setup/db/install.sql');

// installation number value 'n' (WCF_N) must be reflected in the executed sql queries
$sql = \str_replace('wcf1_', 'wcf' . $dbNumber . '_', $sql);

// get all tablenames which should be created
\preg_match_all("%CREATE\\s+TABLE\\s+(\\w+)%", $sql, $matches);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public function getDatabaseConfig()
'password' => $dbConfig['password'],
'username' => $dbConfig['username'],
'dbName' => $dbName,
'dbNumber' => $dbConfig['dbNumber'],
];
}

Expand Down
4 changes: 1 addition & 3 deletions wcfsetup/setup/lang/setup_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@
<item name="wcf.global.configureDB.password"><![CDATA[Kennwort]]></item>
<item name="wcf.global.configureDB.database"><![CDATA[Datenbankname]]></item>
<item name="wcf.global.configureDB.database.description"><![CDATA[Die spezifizierte Datenbank muss bereits angelegt sein.]]></item>
<item name="wcf.global.configureDB.number"><![CDATA[Installationsnummer]]></item>
<item name="wcf.global.configureDB.number.description"><![CDATA[Die Installationsnummer erlaubt Ihnen mehrere Installationen der Software in der gleichen Datenbank zu speichern. Wenn dies Ihre erste Installation der Software in dieser Datenbank ist, sollten Sie hier den Wert <em>1</em> wählen.]]></item>
<item name="wcf.global.configureDB.error"><![CDATA[Beim Verbindungsversuch mit der Datenbank ist folgender Fehler aufgetreten:
<br><strong>{$exception->getMessage()}{if $exception->getPrevious()}<br>{$exception->getPrevious()->getMessage()}{/if}</strong>]]></item>
<item name="wcf.global.configureDB.conflictedTables"><![CDATA[Folgende Tabelle{if $conflictedTables|count > 1}n{/if} existier{if $conflictedTables|count > 1}en{else}t{/if} schon in der Datenbank „{$dbName}“:<br>{implode from=$conflictedTables item="table"}{$table}{/implode}.<br><br>Um dieses Problem zu beheben, können Sie:<br>1. diese Tabelle{if $conflictedTables|count > 1}n{/if} manuell löschen und die „Weiter“ Schaltfläche betätigen, oder<br>2. Sie geben die Daten einer anderen Datenbank ein und betätigen die „Weiter“ Schaltfläche, oder<br>3. Sie geben eine von „{$dbNumber}“ unterschiedliche Installationsnummer an und betätigen die „Weiter“ Schaltfläche.]]></item>
<item name="wcf.global.configureDB.conflictedTables"><![CDATA[Folgende Tabelle{if $conflictedTables|count > 1}n{/if} existier{if $conflictedTables|count > 1}en{else}t{/if} schon in der Datenbank „{$dbName}“:<br>{implode from=$conflictedTables item="table"}{$table}{/implode}.<br><br>Um dieses Problem zu beheben, können Sie:<br>1. diese Tabelle{if $conflictedTables|count > 1}n{/if} manuell löschen und die „Weiter“ Schaltfläche betätigen, oder<br>2. Sie geben die Daten einer anderen Datenbank ein und betätigen die „Weiter“ Schaltfläche.]]></item>
<item name="wcf.global.createUser"><![CDATA[Administrator erstellen]]></item>
<item name="wcf.global.createUser.description"><![CDATA[Der Installationsassistent erstellt nun ein Administrator-Konto für Sie. Bitte geben Sie dazu einen Benutzernamen, eine E-Mail-Adresse und ein Kennwort ein.]]></item>
<item name="wcf.global.createUser.username"><![CDATA[Benutzername]]></item>
Expand Down
4 changes: 1 addition & 3 deletions wcfsetup/setup/lang/setup_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@
<item name="wcf.global.configureDB.password"><![CDATA[Password]]></item>
<item name="wcf.global.configureDB.database"><![CDATA[Database Name]]></item>
<item name="wcf.global.configureDB.database.description"><![CDATA[The database must already exist.]]></item>
<item name="wcf.global.configureDB.number"><![CDATA[Installation Number]]></item>
<item name="wcf.global.configureDB.number.description"><![CDATA[The installation number allows you to install multiple installations of this software into the same database. If this is your first installation in this database, you should enter <em>1</em>.]]></item>
<item name="wcf.global.configureDB.error"><![CDATA[An error has occurred while trying to connect to your database:
<br><strong>{$exception->getMessage()}{if $exception->getPrevious()}<br>{$exception->getPrevious()->getMessage()}{/if}</strong>]]></item>
<item name="wcf.global.configureDB.conflictedTables"><![CDATA[The following table{if $conflictedTables|count > 1}s{/if} already exist{if $conflictedTables|count == 1}s{/if} within your “{$dbName}” Database:<br>{implode from=$conflictedTables item="table"}{$table}{/implode}.<br><br>To solve this problem, please do one of the following:<br>1. Remove the table{if $conflictedTables|count > 1}s{/if} manually and continue the installation with the “Next” button or<br>2. You re-enter the database access information, but to a different database and continue the installation with the “Next” button or<br>3. Enter a new installation number, not forgetting to continue the installation with the “Next” Button.]]></item>
<item name="wcf.global.configureDB.conflictedTables"><![CDATA[The following table{if $conflictedTables|count > 1}s{/if} already exist{if $conflictedTables|count == 1}s{/if} within your “{$dbName}” Database:<br>{implode from=$conflictedTables item="table"}{$table}{/implode}.<br><br>To solve this problem, please do one of the following:<br>1. Remove the table{if $conflictedTables|count > 1}s{/if} manually and continue the installation with the “Next” button or<br>2. You re-enter the database access information, but to a different database and continue the installation with the “Next” button.]]></item>
<item name="wcf.global.createUser"><![CDATA[Create an Administrator]]></item>
<item name="wcf.global.createUser.description"><![CDATA[The installation will now generate an administrator account for you. Please provide username, email address and password.]]></item>
<item name="wcf.global.createUser.username"><![CDATA[Username]]></item>
Expand Down
8 changes: 0 additions & 8 deletions wcfsetup/setup/template/stepConfigureDB.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@
<small>{lang}wcf.global.configureDB.database.description{/lang}</small>
</dd>
</dl>

<dl>
<dt><label for="dbNumber">{lang}wcf.global.configureDB.number{/lang}</label></dt>
<dd>
<input type="number" id="dbNumber" name="dbNumber" value="{$dbNumber}" required min="1" class="short">
<small>{lang}wcf.global.configureDB.number.description{/lang}</small>
</dd>
</dl>
</section>

<div class="formSubmit">
Expand Down