]> granicus.if.org Git - php/commitdiff
Bail if connect.inc gets included twice. Including twice is most likely a 'bug'....
authorUlf Wendel <uw@php.net>
Tue, 20 Oct 2009 08:23:06 +0000 (08:23 +0000)
committerUlf Wendel <uw@php.net>
Tue, 20 Oct 2009 08:23:06 +0000 (08:23 +0000)
ext/mysql/tests/connect.inc

index 86c0ee674852d5e0673aa579a63e288d729b0666..45c41167a0f27ecd371c9e2e862eacebfc3ff858 100755 (executable)
@@ -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");
 }
 
 /*