Search code examples
phpphp-7.1interbasephp-7.2php-7.0

Bug with multiple connections to Interbase with php 7


It seems PHP 7 changed a bit the way to work with the Interbase module.

Same code on PHP 5.6 works flawlessly.

If you have one open link to an Interbase/Firebird database and you open another one to the same database the first link it's closed.

One example of code can be:

$conx = ibase_pconnect(DB_HOST . ":" . DB_NAME,DB_USER,DB_PWD,DB_CHARACTER) or die(ibase_errcode() . ' ' . ibase_errmsg()); 

$conx2 = ibase_pconnect(DB_HOST . ":" . DB_NAME,DB_USER,DB_PWD,DB_CHARACTER) or die(ibase_errcode() . ' ' . ibase_errmsg()); 

$sql = 'SELECT something from somewhere';

$query = ibase_query($conx, $sql);

while ($row = ibase_fetch_assoc($query)) {
    echo $row['something'];
}

DB_xxx are defined variables with the users, password, ..... of the database.

The result it's the same if instead of ibase_pconnect we write ibase_connect

If you run that code you won't get nothing, and on the page log you will see something like:

supplied resource is not a valid Firebird/InterBase link resource in ....

ibase_fetch_assoc(): Dynamic SQL Error SQL error code = -504 Invalid cursor reference Cursor is not open ....

If we remove the line with the $conx2 all will work perfectly.

On my php.ini I have this (exactly the same than on PHP 5.6):

ibase.allow_persistent = 1

; Maximum number of persistent links.  -1 means no limit.
ibase.max_persistent = -1

; Maximum number of links (persistent + non-persistent).  -1 means no limit.
ibase.max_links = -1

Interbase module for php7 has a new option which it's generating this problem ?


Solution

  • It's a php-7.0 bug.

    If was fixed some time ago on version 7.2.16 and was fixed too in lower versions.

    https://bugs.php.net/bug.php?id=72175