Skip to content

Commit 6859dcb

Browse files
committed
Really fix return values
1 parent 96f3448 commit 6859dcb

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

ext/mysqli/mysqli_nonapi.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,18 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, bool is_real_connect, b
355355

356356
mysql->multi_query = 0;
357357

358-
if (!object) {
359-
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry);
360-
} else {
358+
if (object) {
361359
ZEND_ASSERT(instanceof_function(Z_OBJCE_P(object), mysqli_link_class_entry));
362360
(Z_MYSQLI_P(object))->ptr = mysqli_resource;
363-
}
364-
365-
if (!in_ctor) {
366361
RETURN_TRUE;
362+
} else {
363+
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry);
364+
if (is_real_connect) {
365+
zval_ptr_dtor(return_value);
366+
RETURN_TRUE;
367+
} else {
368+
return;
369+
}
367370
}
368371

369372
err:

ext/mysqli/tests/mysqli_connect_twice.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ require_once('skipifconnectfailure.inc');
5959

6060
mysqli_close($link);
6161

62-
if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
63-
printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
62+
if (true !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
63+
printf("[013] Expecting true got %s/%s\n", gettype($tmp), $tmp);
6464

6565
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
6666
printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
6767
$host, $user, $db, $port, $socket);
6868

69-
if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
69+
if (true !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
7070
printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
7171

7272
print "done!";

ext/mysqli/tests/mysqli_pconn_conn_multiple.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ mysqli.max_links=-1
6565

6666
mysqli_close($link);
6767

68-
if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
68+
if (true !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
6969
printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
7070

7171
if (!$link = mysqli_connect($phost, $user, $passwd, $db, $port, $socket))
7272
printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
7373
$phost, $user, $db, $port, $socket);
7474

75-
if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
76-
printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
75+
if (true !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
76+
printf("[015] Expecting true got %s/%s\n", gettype($tmp), $tmp);
7777

7878
printf("Flipping phost/host order\n");
7979

@@ -127,15 +127,15 @@ mysqli.max_links=-1
127127

128128
mysqli_close($link);
129129

130-
if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
131-
printf("[028] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
130+
if (true !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
131+
printf("[028] Expecting true got %s/%s\n", gettype($tmp), $tmp);
132132

133133
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
134134
printf("[029] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
135135
$host, $user, $db, $port, $socket);
136136

137-
if (NULL !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
138-
printf("[030] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
137+
if (true !== ($tmp = $link->connect($phost, $user, $passwd, $db, $port, $socket)))
138+
printf("[030] Expecting true got %s/%s\n", gettype($tmp), $tmp);
139139

140140
print "done!";
141141
?>

ext/mysqli/tests/mysqli_pconn_twice.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ mysqli.max_links=-1
5252

5353
mysqli_close($link);
5454

55-
if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
56-
printf("[013] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
55+
if (true !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
56+
printf("[013] Expecting true got %s/%s\n", gettype($tmp), $tmp);
5757

5858
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
5959
printf("[014] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
6060
$host, $user, $db, $port, $socket);
6161

62-
if (NULL !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
63-
printf("[015] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
62+
if (true !== ($tmp = $link->connect($host, $user, $passwd, $db, $port, $socket)))
63+
printf("[015] Expecting true got %s/%s\n", gettype($tmp), $tmp);
6464

6565
print "done!";
6666
?>

0 commit comments

Comments
 (0)