Annotation of embedaddon/php/ext/mysql/tests/bug48754.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #48754 (mysql_close() crash php when no handle specified)
! 3: --SKIPIF--
! 4: <?php
! 5: require_once('skipif.inc');
! 6: require_once('skipifconnectfailure.inc');
! 7: ?>
! 8: --FILE--
! 9: <?php
! 10: require_once('connect.inc');
! 11:
! 12: function my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket) {
! 13: if ($socket)
! 14: $host = sprintf("%s:%s", $host, $socket);
! 15: else if ($port)
! 16: $host = sprintf("%s:%s", $host, $port);
! 17:
! 18: if (!$link = mysql_pconnect($host, $user, $passwd, true)) {
! 19: printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n",
! 20: $host, $user, $passwd,
! 21: mysql_errno(), mysql_error());
! 22: return false;
! 23: }
! 24: return $link;
! 25: }
! 26:
! 27: echo "Explicit connection on close\n";
! 28: $link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket);
! 29: $link1_thread_id = mysql_thread_id($link);
! 30: $default1_thread_id = mysql_thread_id();
! 31: echo 'Expect same thread id for $link and default conn: ';
! 32: var_dump($link1_thread_id == $default1_thread_id);
! 33: var_dump($link);
! 34: mysql_close($link);
! 35: var_dump($link);
! 36:
! 37: // we sohuld have no default link anymore
! 38: mysql_close();
! 39:
! 40: echo "\nClosing default link\n";
! 41: $link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket);
! 42: $link2_thread_id = mysql_thread_id($link);
! 43: $default2_thread_id = mysql_thread_id();
! 44: echo 'Expect same thread id for $link and default conn but not the previous: ';
! 45: var_dump($link1_thread_id == $default1_thread_id && $link1_thread_id != $link2_thread_id);
! 46: var_dump($link);
! 47: mysql_close();
! 48: var_dump($link);
! 49: mysql_close($link);
! 50: var_dump($link);
! 51:
! 52: echo "\nExplicit resource and pconnect\n";
! 53: $link = my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket);
! 54: var_dump($link);
! 55: mysql_close($link);
! 56: var_dump($link);
! 57:
! 58: // we sohuld have no default link
! 59: mysql_close();
! 60:
! 61: echo "\nDefault link and pconnect\n";
! 62: $link = my_mysql_pconnect($host, $user, $passwd, $db, $port, $socket);
! 63: var_dump($link);
! 64: mysql_close();
! 65: var_dump($link);
! 66: mysql_close($link);
! 67: var_dump($link);
! 68: ?>
! 69: --EXPECTF--
! 70: Explicit connection on close
! 71: Expect same thread id for $link and default conn: bool(true)
! 72: resource(%d) of type (mysql link)
! 73: resource(%d) of type (Unknown)
! 74:
! 75: Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d
! 76:
! 77: Closing default link
! 78: Expect same thread id for $link and default conn but not the previous: bool(true)
! 79: resource(%d) of type (mysql link)
! 80: resource(%d) of type (mysql link)
! 81: resource(%d) of type (Unknown)
! 82:
! 83: Explicit resource and pconnect
! 84: resource(%d) of type (mysql link persistent)
! 85: resource(%d) of type (Unknown)
! 86:
! 87: Warning: mysql_close(): no MySQL-Link resource supplied in %s on line %d
! 88:
! 89: Default link and pconnect
! 90: resource(%d) of type (mysql link persistent)
! 91: resource(%d) of type (mysql link persistent)
! 92: resource(%d) of type (Unknown)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>