Merge branch 'PHP-8.4'

* PHP-8.4:
  [skip ci] Update NEWS
  Fix bug and add test for dba_open same file twice (#17979)
This commit is contained in:
Gina Peter Banyard 2025-03-11 11:11:25 +00:00
commit 38fce780d9
No known key found for this signature in database
GPG key ID: F30F8C1ACF51943F
2 changed files with 36 additions and 1 deletions

View file

@ -57,6 +57,7 @@ ZEND_BEGIN_MODULE_GLOBALS(dba)
const char *default_handler; const char *default_handler;
const dba_handler *default_hptr; const dba_handler *default_hptr;
HashTable connections; HashTable connections;
unsigned int connection_counter;
ZEND_END_MODULE_GLOBALS(dba) ZEND_END_MODULE_GLOBALS(dba)
ZEND_DECLARE_MODULE_GLOBALS(dba) ZEND_DECLARE_MODULE_GLOBALS(dba)
@ -569,7 +570,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)
} }
zend_string *resource_key = zend_strpprintf(0, zend_string *resource_key = zend_strpprintf(0,
"dba_%d_%s_%s_%s", persistent, ZSTR_VAL(path), ZSTR_VAL(mode), handler_str ? ZSTR_VAL(handler_str) : "" "dba_%d_%u_%s_%s_%s", persistent, persistent ? 0 : DBA_G(connection_counter)++, ZSTR_VAL(path), ZSTR_VAL(mode), handler_str ? ZSTR_VAL(handler_str) : ""
); );
if (persistent) { if (persistent) {

View file

@ -0,0 +1,34 @@
--TEST--
DBA open same read only file multiple times
--EXTENSIONS--
dba
--SKIPIF--
<?php
require_once __DIR__ . '/setup/setup_dba_tests.inc';
check_skip('cdb_make');
?>
--CONFLICTS--
test.cdb
--FILE--
<?php
echo "database handler: cdb\n";
$handler = 'cdb';
$db_filename = __DIR__.'/test.cdb';
if (($db_file=dba_open($db_filename, "r", $handler))!==FALSE) {
echo dba_fetch(1, $db_file);
if (($db_file2=dba_open($db_filename, "r", $handler))!==FALSE) {
echo dba_fetch(1, $db_file2);
echo dba_fetch(2, $db_file2);
dba_close($db_file2);
} else {
echo "Error opening database 2nd time\n";
}
echo dba_fetch(2, $db_file);
dba_close($db_file);
} else {
echo "Error opening database\n";
}
?>
--EXPECT--
database handler: cdb
1122