[BUGFIX] Support mysql socket connection 73/21973/3
authorPhilipp Gampe <philipp.gampe@typo3.org>
Mon, 20 May 2013 14:58:20 +0000 (16:58 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 5 Jul 2013 21:22:40 +0000 (23:22 +0200)
With the switch to mysqli in 6.1, the connection to mysql server via
socket broke.
With mysqli, the definition is now:
* If hostname is "localhost", a socket is used and the socket file
can be given optionally if it is different from the default.
* If hostname is not "localhost" but an IP address, a port can be
given that may be different from the default mysql 3306.

This backport just considers the LocalConfiguration.php setting and
does not change anything in the installer.

Resolves: #48117
Releases: 6.2, 6.1
Change-Id: I968a72dbaf90b3f319c03e697137630534d325c1
Reviewed-on: https://review.typo3.org/21973
Reviewed-by: Markus Klein
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Database/DatabaseConnection.php

index 7d59ce5..3f6799a 100644 (file)
@@ -677,7 +677,6 @@ class Bootstrap {
        /**
         * Initialize database connection in $GLOBALS and connect if requested
         *
-        * @param boolean $connect Whether db should be connected
         * @return \TYPO3\CMS\Core\Core\Bootstrap
         * @internal This is not a public API method, do not use in own extensions
         */
@@ -696,6 +695,9 @@ class Bootstrap {
                        list($databaseHost, $databasePort) = explode(':', $databaseHost);
                        $databaseConnection->setDatabasePort($databasePort);
                }
+               if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['socket'])) {
+                       $databaseConnection->setDatabaseSocket($GLOBALS['TYPO3_CONF_VARS']['DB']['socket']);
+               }
                $databaseConnection->setDatabaseHost($databaseHost);
 
                $databaseConnection->debugOutput = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'];
index ef8a3c3..032c346 100644 (file)
@@ -106,6 +106,11 @@ class DatabaseConnection {
        protected $databasePort = 3306;
 
        /**
+        * @var string|NULL Database socket to connect to
+        */
+       protected $databaseSocket = NULL;
+
+       /**
         * @var string Database name to connect to
         */
        protected $databaseName = '';
@@ -1184,7 +1189,7 @@ class DatabaseConnection {
                        $this->databaseUserPassword,
                        NULL,
                        $this->databasePort,
-                       NULL,
+                       $this->databaseSocket,
                        $this->connectionCompression ? MYSQLI_CLIENT_COMPRESS : 0
                );
 
@@ -1438,6 +1443,16 @@ class DatabaseConnection {
        }
 
        /**
+        * Set database socket
+        *
+        * @param string|NULL $socket
+        */
+       public function setDatabaseSocket($socket = NULL) {
+               $this->disconnectIfConnected();
+               $this->databaseSocket = $socket;
+       }
+
+       /**
         * Set database name
         *
         * @param string $name
@@ -1814,6 +1829,7 @@ class DatabaseConnection {
                        'explainOutput',
                        'databaseHost',
                        'databasePort',
+                       'databaseSocket',
                        'databaseName',
                        'databaseUsername',
                        'databaseUserPassword',