mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
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:
commit
38fce780d9
2 changed files with 36 additions and 1 deletions
|
@ -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) {
|
||||||
|
|
34
ext/dba/tests/dba_duplicateopen.phpt
Normal file
34
ext/dba/tests/dba_duplicateopen.phpt
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue