summaryrefslogtreecommitdiff
path: root/ext/mysql
diff options
context:
space:
mode:
authorUlf Wendel <uw@php.net>2009-10-20 08:23:06 +0000
committerUlf Wendel <uw@php.net>2009-10-20 08:23:06 +0000
commit121aceb04e1ce242558c2cbc3308a41ff0e1160f (patch)
treea46d2a4e7f4173bee1b6bce584feee93ebd05701 /ext/mysql
parentff3ba767ec01f6a38232e285ad2767144adf74e0 (diff)
downloadphp-git-121aceb04e1ce242558c2cbc3308a41ff0e1160f.tar.gz
Bail if connect.inc gets included twice. Including twice is most likely a 'bug'. See also http://news.php.net/php.cvs/60720
Diffstat (limited to 'ext/mysql')
-rwxr-xr-xext/mysql/tests/connect.inc42
1 files 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");
}
/*