Bug #79591 [Com]: mysqli::$errno not an integer after connection close

From: Date: Tue, 12 May 2020 17:13:09 +0000
Subject: Bug #79591 [Com]: mysqli::$errno not an integer after connection close
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227017@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79591&edit=1

 ID:                 79591
 Comment by:         vedad at kajtaz dot net
 Reported by:        vedad at kajtaz dot net
 Summary:            mysqli::$errno not an integer after connection close
 Status:             Open
 Type:               Bug
 Package:            MySQLi related
 Operating System:   FreeBSD 12.1-RELEASE
 PHP Version:        7.4.5
 Block user comment: N
 Private report:     N

 New Comment:

Somehow related, there is also mysqli::$info resolving to null instead of empty string, as stated in
the documentation:

> Queries which do not fall into one of the preceding formats are not supported. In these
> situations, mysqli_info() will return an empty string.


Previous Comments:
------------------------------------------------------------------------
[2020-05-12 15:56:20] vedad at kajtaz dot net

Description:
------------
The documentation states that mysqli::$errno is an integer.

Once the mysqli connection was closed, it resolves to boolean false instead.

This is annoying when mysqli::$errno is being passed as second argument to \Throwable, which
triggers an Error with strict_types enabled.

Test script:
---------------
$mysqli = mysqli_init();

assert(is_int($mysqli->errno) && 'before connect');

assert($mysqli->real_connect(...));

assert(is_int($mysqli->errno) && 'before close');

$mysqli->close();

assert(is_int($mysqli->errno) && 'after close');


Actual result:
--------------
PHP Fatal error:  Uncaught AssertionError: assert(is_int($mysqli->errno) && 'after
close')


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79591&edit=1


Thread (2 messages)

« previous php.bugs (#227017) next »