Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-updates-src > by-pkgid > c50e1cad1a7e9829787265c1c65bfbb8 > files > 11

php-5.6.35-1.mga5.src.rpm

From 061fa11d7f90905f00893f02f0e4b1e0267b7cd5 Mon Sep 17 00:00:00 2001
From: Olivier Blin <dev@blino.org>
Date: Sun, 23 Jun 2013 23:04:47 +0200
Subject: [PATCH] mysqlnd: detect mysql unix socket path with mysql_config

When the mysql extension is disabled, there is no automatic detection
of the mysql unix socket path.
The mysqli/mysqlnd/pdo_mysql use a hardcoded /tmp/mysql.sock path.

This adds automatic detection of the mysql unix socket path in mysqlnd
with mysql_config --socket, and makes pdo_mysql use it as well.
---
 ext/mysqlnd/config9.m4    | 12 ++++++++++--
 ext/mysqlnd/mysqlnd.c     |  4 ++++
 ext/pdo_mysql/pdo_mysql.c | 10 +++++++---
 3 files changed, 21 insertions(+), 5 deletions(-)

diff -Naurp php-5.5.9/ext/mysqlnd/config9.m4 php-5.5.9.oden/ext/mysqlnd/config9.m4
--- php-5.5.9/ext/mysqlnd/config9.m4	2014-02-05 11:00:36.000000000 +0100
+++ php-5.5.9.oden/ext/mysqlnd/config9.m4	2014-02-12 11:16:58.513818477 +0100
@@ -3,8 +3,9 @@ dnl $Id$
 dnl config.m4 for mysqlnd driver
 
 PHP_ARG_ENABLE(mysqlnd, whether to enable mysqlnd,
-  [  --enable-mysqlnd        Enable mysqlnd explicitly, will be done implicitly
-                          when required by other extensions], no, yes)
+  [  --enable-mysqlnd=FILE Enable mysqlnd explicitly, will be done implicitly
+                           when required by other extensions. FILE is the path
+                           to mysql_config.], no, yes)
 
 PHP_ARG_ENABLE(mysqlnd_compression_support, whether to disable compressed protocol support in mysqlnd,
 [  --disable-mysqlnd-compression-support
@@ -17,6 +18,8 @@ fi
 
 dnl If some extension uses mysqlnd it will get compiled in PHP core
 if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
+  MYSQL_CONFIG=$PHP_MYSQLND
+
   mysqlnd_ps_sources="mysqlnd_ps.c mysqlnd_ps_codec.c"
   mysqlnd_base_sources="mysqlnd.c mysqlnd_alloc.c mysqlnd_bt.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
                    mysqlnd_loaddata.c mysqlnd_reverse_api.c mysqlnd_net.c \
@@ -44,6 +47,11 @@ if test "$PHP_MYSQLND" != "no" || test "
   PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, $ext_shared)
   PHP_ADD_BUILD_DIR([ext/mysqlnd], 1)
   PHP_INSTALL_HEADERS([ext/mysqlnd/])
+
+  if test -x "$MYSQL_CONFIG"; then
+    MYSQLND_SOCKET=`$MYSQL_CONFIG --socket`
+    AC_DEFINE_UNQUOTED(MYSQLND_UNIX_SOCK_ADDR, "$MYSQLND_SOCKET", [ ])
+  fi
 fi
 
 if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes" || test "$PHP_MYSQLI" != "no"; then
diff -Naurp php-5.5.9/ext/mysqlnd/mysqlnd.c php-5.5.9.oden/ext/mysqlnd/mysqlnd.c
--- php-5.5.9/ext/mysqlnd/mysqlnd.c	2014-02-05 11:00:36.000000000 +0100
+++ php-5.5.9.oden/ext/mysqlnd/mysqlnd.c	2014-02-12 11:16:58.513818477 +0100
@@ -920,7 +920,11 @@ MYSQLND_METHOD(mysqlnd_conn_data, connec
 		if (host_len == sizeof("localhost") - 1 && !strncasecmp(host, "localhost", host_len)) {
 			DBG_INF_FMT("socket=%s", socket_or_pipe? socket_or_pipe:"n/a");
 			if (!socket_or_pipe) {
+#ifdef MYSQLND_UNIX_SOCK_ADDR
+				socket_or_pipe = MYSQLND_UNIX_SOCK_ADDR;
+#else
 				socket_or_pipe = "/tmp/mysql.sock";
+#endif
 			}
 			transport_len = mnd_sprintf(&transport, 0, "unix://%s", socket_or_pipe);
 			unix_socket = TRUE;
diff -Naurp php-5.5.9/ext/pdo_mysql/pdo_mysql.c php-5.5.9.oden/ext/pdo_mysql/pdo_mysql.c
--- php-5.5.9/ext/pdo_mysql/pdo_mysql.c	2014-02-05 11:00:36.000000000 +0100
+++ php-5.5.9.oden/ext/pdo_mysql/pdo_mysql.c	2014-02-12 11:16:58.513818477 +0100
@@ -49,10 +49,14 @@ ZEND_DECLARE_MODULE_GLOBALS(pdo_mysql)
 # ifdef PHP_MYSQL_UNIX_SOCK_ADDR
 #  define PDO_MYSQL_UNIX_ADDR PHP_MYSQL_UNIX_SOCK_ADDR
 # else
-#  if !PHP_WIN32
-#   define PDO_MYSQL_UNIX_ADDR "/tmp/mysql.sock"
+#  ifdef MYSQLND_UNIX_SOCK_ADDR
+#   define PDO_MYSQL_UNIX_ADDR MYSQLND_UNIX_SOCK_ADDR
 #  else
-#   define PDO_MYSQL_UNIX_ADDR NULL
+#   if !PHP_WIN32
+#    define PDO_MYSQL_UNIX_ADDR "/tmp/mysql.sock"
+#   else
+#    define PDO_MYSQL_UNIX_ADDR NULL
+#   endif
 #  endif
 # endif
 #endif