]> git.pld-linux.org Git - packages/cacti.git/blob - mysql-socket.patch
make logrotate compatible with ac
[packages/cacti.git] / mysql-socket.patch
1 allow using socket to connect to mysql
2
3 split the socket from port if hostname contains colon
4 this also allows $port to be just path to socket (not-numeric)
5
6 localhost:/tmp/sock inspired by:
7 http://bugs.cacti.net/view.php?id=425
8
9 note: this socket works for mysqli driver only:
10 http://phplens.com/lens/adodb/docs-adodb.htm
11
12
13 --- cacti-0.8.7i-PIA-3.1/lib/database.php~      2011-12-12 03:56:06.000000000 +0200
14 +++ cacti-0.8.7i-PIA-3.1/lib/database.php       2012-01-24 11:18:39.563094454 +0200
15 @@ -34,6 +34,11 @@
16  function db_connect_real($host, $user, $pass, $db_name, $db_type, $port = "3306", $db_ssl = false, $retries = 20) {
17         global $cnn_id;
18  
19 +       // convert hostname:port to hostname and port
20 +       if (strchr($host, ':')) {
21 +               list($host, $port) = explode(':', $host, 2);
22 +       }
23 +
24         $i = 0;
25         $dsn = "$db_type://" . rawurlencode($user) . ":" . rawurlencode($pass) . "@" . rawurlencode($host) . "/" . rawurlencode($db_name) . "?persist";
26  
27 @@ -43,7 +48,10 @@
28                 $dsn .= "&clientflags=" . MYSQLI_CLIENT_SSL;
29         }
30  
31 -       if ($port != "3306") {
32 +       // socket supported for mysqli only, not mysql
33 +       if ($port && !is_numeric($port)) {
34 +               $dsn .= "&socket=" . $port;
35 +       } elseif ($port != "3306") {
36                 $dsn .= "&port=" . $port;
37         }
38  
This page took 0.056834 seconds and 3 git commands to generate.