diff options
author | Nikita Popov <nikic@php.net> | 2017-01-03 12:18:33 +0100 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2017-01-03 12:18:33 +0100 |
commit | 661fad7beb71d1096e93b0212624ad5f94e5a648 (patch) | |
tree | 7a225aa3855d91aec21b4b45fc9feb65f4ad3f39 /ext | |
parent | e42a01bcd54eaaa62e18a648a4a310063bd0abf1 (diff) | |
parent | b3889d4b20aaec16ceb89fe64e42de7c464e20e1 (diff) | |
download | php-git-661fad7beb71d1096e93b0212624ad5f94e5a648.tar.gz |
Merge branch 'PHP-7.0' into PHP-7.1
Diffstat (limited to 'ext')
-rw-r--r-- | ext/mysqli/mysqli_nonapi.c | 4 | ||||
-rw-r--r-- | ext/mysqli/tests/bug73462.phpt | 41 | ||||
-rw-r--r-- | ext/standard/pack.c | 4 |
3 files changed, 47 insertions, 2 deletions
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index e3efca25c6..83de52dcf5 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -183,6 +183,10 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne mysqlnd_restart_psession(mysql->mysql); #endif MyG(num_active_persistent)++; + + /* clear error */ + php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql)); + goto end; } else { mysqli_close(mysql->mysql, MYSQLI_CLOSE_IMPLICIT); diff --git a/ext/mysqli/tests/bug73462.phpt b/ext/mysqli/tests/bug73462.phpt new file mode 100644 index 0000000000..6de73761f4 --- /dev/null +++ b/ext/mysqli/tests/bug73462.phpt @@ -0,0 +1,41 @@ +--TEST-- +Bug #73462 (Persistent connections don't set $connect_errno) +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifemb.inc'); +require_once('skipifconnectfailure.inc'); +?> +--FILE-- +<?php + require_once("connect.inc"); + + /* Initial persistent connection */ + $mysql_1 = new mysqli('p:'.$host, $user, $passwd, $db); + $result = $mysql_1->query("SHOW STATUS LIKE 'Connections'"); + $c1 = $result->fetch_row(); + $result->free(); + $mysql_1->close(); + + /* Failed connection to invalid host */ + $mysql_2 = @new mysqli(' !!! invalid !!! ', $user, $passwd, $db); + @$mysql_2->close(); + + /* Re-use persistent connection */ + $mysql_3 = new mysqli('p:'.$host, $user, $passwd, $db); + $error = mysqli_connect_errno(); + $result = $mysql_3->query("SHOW STATUS LIKE 'Connections'"); + $c3 = $result->fetch_row(); + $result->free(); + $mysql_3->close(); + + if (end($c1) !== end($c3)) + printf("[001] Expected '%d' got '%d'.\n", end($c1), end($c3)); + + if ($error !== 0) + printf("[002] Expected '0' got '%d'.\n", $error); + + print "done!"; +?> +--EXPECTF-- +done! diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 261e97ce8b..0707371322 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -106,7 +106,7 @@ static void php_pack(zval *val, size_t size, int *map, char *output) /* {{{ php_pack_reverse_int32 */ -inline uint32_t php_pack_reverse_int32(uint32_t arg) +static inline uint32_t php_pack_reverse_int32(uint32_t arg) { uint32_t result; result = ((arg & 0xFF) << 24) | ((arg & 0xFF00) << 8) | ((arg >> 8) & 0xFF00) | ((arg >> 24) & 0xFF); @@ -117,7 +117,7 @@ inline uint32_t php_pack_reverse_int32(uint32_t arg) /* {{{ php_pack */ -inline uint64_t php_pack_reverse_int64(uint64_t arg) +static inline uint64_t php_pack_reverse_int64(uint64_t arg) { union Swap64 { uint64_t i; |