Remove the WCF_N input in WCFSetup
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 12 May 2022 09:04:02 +0000 (11:04 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 12 May 2022 09:08:06 +0000 (11:08 +0200)
Users should install separate instances into separate databases for security
reasons. This also avoids issues with users running a non-standard number and
any existing guides / queries not working, because the database tables have a
different name.

extra/examples/wsc-dev-config-55.json
wcfsetup/install/files/lib/system/WCFSetup.class.php
wcfsetup/install/files/lib/system/devtools/DevtoolsSetup.class.php
wcfsetup/setup/lang/setup_de.xml
wcfsetup/setup/lang/setup_en.xml
wcfsetup/setup/template/stepConfigureDB.tpl

index 605aa81ebf8de8dbcfb5fcc1a6a1a4a11e9771a9..24b5118aa7e29c5a9209fc24749d92d69433f9d9 100644 (file)
@@ -4,8 +4,7 @@
             "auto": true,
             "host": "localhost",
             "password": "root",
-            "username": "root",
-            "dbNumber": "2"
+            "username": "root"
         },
         "useDefaultInstallPath": true,
         "forceStaticCookiePrefix": true
index 607e4315cfba8499a361f444a96f83de91e8609a..792ed2893d89ccf7129241294f30983399beab27 100644 (file)
@@ -651,7 +651,6 @@ class WCFSetup extends WCF
             $dbUser = $_ENV['WCFSETUP_DBUSER'];
             $dbPassword = $_ENV['WCFSETUP_DBPASSWORD'];
             $dbName = $_ENV['WCFSETUP_DBNAME'];
-            $dbNumber = 1;
 
             $attemptConnection = true;
         } elseif (self::$developerMode && ($config = DevtoolsSetup::getInstance()->getDatabaseConfig()) !== null) {
@@ -659,7 +658,6 @@ class WCFSetup extends WCF
             $dbUser = $config['username'];
             $dbPassword = $config['password'];
             $dbName = $config['dbName'];
-            $dbNumber = $config['dbNumber'];
 
             if ($config['auto']) {
                 $attemptConnection = true;
@@ -669,7 +667,6 @@ class WCFSetup extends WCF
             $dbUser = 'root';
             $dbPassword = '';
             $dbName = 'wcf';
-            $dbNumber = 1;
         }
 
         if ($attemptConnection) {
@@ -686,11 +683,6 @@ class WCFSetup extends WCF
                 $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;
@@ -790,7 +782,7 @@ class WCFSetup extends WCF
                 */
 
                 // check for table conflicts
-                $conflictedTables = $this->getConflictedTables($db, $dbNumber);
+                $conflictedTables = $this->getConflictedTables($db);
 
                 // write config.inc
                 if (empty($conflictedTables)) {
@@ -803,7 +795,7 @@ class WCFSetup extends WCF
                     $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
@@ -823,7 +815,6 @@ class WCFSetup extends WCF
             'dbUser' => $dbUser,
             'dbPassword' => $dbPassword,
             'dbName' => $dbName,
-            'dbNumber' => $dbNumber,
             'nextStep' => 'configureDB',
         ]);
         WCF::getTPL()->display('stepConfigureDB');
@@ -834,17 +825,13 @@ class WCFSetup extends WCF
      * 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);
 
index ba35890fdf76fe314fb3e84dbe154bc5dad376b2..62e44910d656d178c55eb51816d4c8909b6391fa 100644 (file)
@@ -79,7 +79,6 @@ class DevtoolsSetup extends SingletonFactory
             'password' => $dbConfig['password'],
             'username' => $dbConfig['username'],
             'dbName' => $dbName,
-            'dbNumber' => $dbConfig['dbNumber'],
         ];
     }
 
index 8bac0d1ba241e702299fd1ea386aa9e087d12bb4..86ea5f2d652bf1c936610134f785303dd3401ddb 100644 (file)
                <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>
index cfa8e785e0cdeb528a2a945314766bd7d6a5799e..aad35e741acd8dc6e4f5503beb6b514acd5ef72f 100644 (file)
                <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>
index 446f4ef199e972fa369c8cece319aa4e4ad51093..0329f8abb44343a9dd06181f5ac85308a8994e39 100644 (file)
                                <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">