Lots of errors on closing mysql connection in PHP under Linux (Komodo IDE 8.5)

When I close an opened mysqli DB connection I get lots of errors.

This is the script stripped to a minimum to reproduce the error:

<?php
$erl = error_reporting(E_ALL);
$dbh = new mysqli( 'localhost', 'video', '******', 'recordings');
$dbh->close();
$x=1;
$x=2;
?>

I get a bunch of errors (see below) when I execute the line with “$dbh->close()” and on ALL SUBSEQUENT LINES until the script terminates.
To be exact: I get these errors every time the script stops due to a breakpoint or in single step.

The line number shown is NOT the line just executed but the line number where the cursor sits AFTER stopping.

The database connection is established and is working. (The real script does what it should do)
I only get these errors when debugging.
No errors when running on the command line.
No errors when running inside Komodo with “Run without debugging” or when the script doesn’t have breakpoints.
If the script has a breakpoint (at or after the close() statement) the first error is thrown when I reach that breakpoint.

Here are the errors I get.

PHP Warning:  main(): Property access is not allowed yet in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Property access is not allowed yet in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Property access is not allowed yet in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Property access is not allowed yet in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0
PHP Warning:  main(): Couldn't fetch mysqli in /home/livespotting/lsm_encoding-master/htdocs/test.php on line 6
PHP Stack trace:
PHP   1. {main}() /home/livespotting/lsm_encoding-master/htdocs/test.php:0

Update:
Today I found out: When I do the close() inside a function the errors stop when the function returns.
Still weird but at least some kind of solution for now.

Glad you got it sorted :slight_smile: Note these forums are meant for Komodo support, whilst you’re free to ask about programming issues you are likely better off using a site specifically meant for that, eg. Stackoverflow.

Edit: My bad, I had read your message too fast. Could you post the full code snippet you are using? The errors are referring to line 6, but that does not seem to correspond to the snippet you posted.

Hi natanr,

This IS the code in question. What you cannot see is the brakpoint at line 6 (the $x=2;)
The debugger stops here for the first time. Every time the debugger stops (after the close()) I get these messages, always with the current line number.

A guess:
I don’t know how Komodo works internally, but maybe…
When the script stops, Komodo tries to collect the values of all variables in use. For some reason it has missed that the database connection is no longer valid and tries to retreive lots of variables that doesn’t exist anymore.

???

@Paul_S

It looks like there is a bug in MySQLi.Someone had issues with it in another IDE as well: http://stackoverflow.com/questions/25377030/mysqli-xdebug-breakpoint-after-closing-statment-result-in-many-warnings

Unfortunately it appears to have been around for a while @Paul_S. It looks like some people get around it by using mysqlnd.

  • Carey

Thank you, careyh.

For the curious. This is the solution/workaround to the problem:

<?php
$erl = error_reporting(E_ALL);
$dbh = new mysqli( 'localhost', 'video', '******', 'recordings');
$dbh->close();
unset($dbh);  # <----- This makes the errors go away
$x=1;
$x=2;
?>

One guy in the stackoverflow thread reported a failure, but for me and others this worked well.

Thanks to all for taking care,

Paul

P.S. Can this be marked as solved?

Done, thanks for following up :slight_smile:

Awesome! Thanks for following up @Paul_S! Glad we could help!

I’m finding that an unset() after closing the connection doesn’t help, because Komodo IDE freezes for awhile before it even gets there – specifically, on the mysqli_close(), as it receives several copies of those errors “Property access is not allowed yet…” and “Couldn’t fetch mysqli…”" mentioned in the Stack Overflow post. It doesn’t occur when running the code normally, but does when debugging it in Komodo IDE step by step.

Here’s a simplified procedural version of the code. (As one would guess, SQL_database_settings() is a custom function that returns an array of the needed database access info.)

list( $db_scheme, $db_host, $db_user, $db_pass, $db_name ) = SQL_database_settings();
$connection = mysqli_connect( $db_host, $db_user, $db_pass );
mysqli_close( $connection );
unset( $connection );

The same problem occurs using object-oriented code (similar to @Paul_S’s code):

list( $db_scheme, $db_host, $db_user, $db_pass, $db_name ) = SQL_database_settings();
$connection = new mysqli( $db_host, $db_user, $db_pass, $db_name );
$connection->close();
unset( $connection );

Any suggestions? (No worries if nothing comes to mind, as the ultimate source of the problem isn’t Komodo IDE.)