[BUGFIX] Fix front end redirect to 1-2-3 installer
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 13 Jul 2011 21:03:05 +0000 (23:03 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Sat, 16 Jul 2011 17:02:38 +0000 (19:02 +0200)
An empty value in the TYPO3_db constant indicates a not configured installation in
the front end. The front end then redirects to 1-2-3 installer.
This broke with change 89732c4a of #27954 because the check for db constant
is done too late.

Change the order of the checks during database connection and
check if the TYPO3_db constant has a value first.

Change-Id: I0a7003d876a747e16552fecf6385b0449de5617a
Resolves: #28185
Related: #27954
Reviewed-on: http://review.typo3.org/3316
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Stefan Neufeind
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
t3lib/class.t3lib_db.php

index d9a2107..3d614e4 100644 (file)
@@ -1339,13 +1339,17 @@ class t3lib_DB {
         * @return      void
         */
        function connectDB($host = TYPO3_db_host, $user = TYPO3_db_username, $password = TYPO3_db_password, $db = TYPO3_db) {
+                       // If no db is given we throw immediately. This is a sign for a fresh (not configured)
+                       // TYPO3 installation and is used in FE to redirect to 1-2-3 install tool
+               if (!$db) {
+                       throw new RuntimeException(
+                               'TYPO3 Fatal Error: No database selected!',
+                               1270853882
+                       );
+               }
+
                if ($this->sql_pconnect($host, $user, $password)) {
-                       if (!$db) {
-                               throw new RuntimeException(
-                                       'TYPO3 Fatal Error: No database selected!',
-                                       1270853882
-                               );
-                       } elseif (!$this->sql_select_db($db)) {
+                       if (!$this->sql_select_db($db)) {
                                throw new RuntimeException(
                                        'TYPO3 Fatal Error: Cannot connect to the current database, "' . $db . '"!',
                                        1270853883