From 9bb4db87811616600b1a2bf52bc9ba2091489f1d Mon Sep 17 00:00:00 2001 From: Ulf Wendel Date: Tue, 20 Oct 2009 08:23:06 +0000 Subject: [PATCH] Bail if connect.inc gets included twice. Including twice is most likely a 'bug'. See also http://news.php.net/php.cvs/60720 --- ext/mysql/tests/connect.inc | 42 ++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/ext/mysql/tests/connect.inc b/ext/mysql/tests/connect.inc index 86c0ee6748..45c41167a0 100755 --- a/ext/mysql/tests/connect.inc +++ b/ext/mysql/tests/connect.inc @@ -19,30 +19,34 @@ if (!function_exists('sys_get_temp_dir')) { } } -/* wrapper to simplify test porting */ -function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL) { - global $connect_flags; +if (!function_exists('my_mysql_connect')) { + /* wrapper to simplify test porting */ + function my_mysql_connect($host, $user, $passwd, $db, $port, $socket, $flags = NULL) { + global $connect_flags; - $flags = ($flags === NULL) ? $connect_flags : $flags; + $flags = ($flags === NULL) ? $connect_flags : $flags; - if ($socket) - $host = sprintf("%s:%s", $host, $socket); - else if ($port) - $host = sprintf("%s:%s", $host, $port); + if ($socket) + $host = sprintf("%s:%s", $host, $socket); + else if ($port) + $host = sprintf("%s:%s", $host, $port); - if (!$link = mysql_connect($host, $user, $passwd, true, $flags)) { - printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n", - $host, $user, $passwd, - mysql_errno(), mysql_error()); - return false; - } + if (!$link = mysql_connect($host, $user, $passwd, true, $flags)) { + printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n", + $host, $user, $passwd, + mysql_errno(), mysql_error()); + return false; + } - if (!mysql_select_db($db, $link)) { - printf("[000-b] [%d] %s\n", mysql_errno($link), mysql_error($link)); - return false; - } + if (!mysql_select_db($db, $link)) { + printf("[000-b] [%d] %s\n", mysql_errno($link), mysql_error($link)); + return false; + } - return $link; + return $link; + } +} else { + printf("skip Eeeek/BUG/FIXME - connect.inc included twice! skipif bug?\n"); } /* -- 2.40.0