From d98a45d08c2b1de7f9c9f6a3ab25886018a206df Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 19 Dec 2023 17:42:52 +0000 Subject: [PATCH] ext/pgsql: pgsql.allow_persistent, no need to use such large type for boolean state. also ext/odbc, simplifying odd comparison with non persistent connections. Close GH-12976 --- NEWS | 3 +++ ext/odbc/php_odbc.c | 2 +- ext/pgsql/pgsql.c | 2 +- ext/pgsql/php_pgsql.h | 5 +++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 9960d2eafca..dc21c25772f 100644 --- a/NEWS +++ b/NEWS @@ -43,6 +43,9 @@ PHP NEWS . Fixed bug GH-12767 (Unable to turn on autocommit mode with setAttribute()). (SakiTakamachi) +- PGSQL: + . Fixed auto_reset_persistent handling and allow_persistent type. (David Carlier) + - PHPDBG: . Fixed bug GH-12962 (Double free of init_file in phpdbg_prompt.c). (nielsdos) diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index fa9d8330fe6..d03a0790a72 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -2194,7 +2194,7 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) } } - if (ODBCG(allow_persistent) <= 0) { + if (!ODBCG(allow_persistent)) { persistent = 0; } diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index f3c4471837d..a437c1620de 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -405,7 +405,7 @@ PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN( "pgsql.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_persistent, zend_pgsql_globals, pgsql_globals) STD_PHP_INI_ENTRY_EX("pgsql.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_persistent, zend_pgsql_globals, pgsql_globals, display_link_numbers) STD_PHP_INI_ENTRY_EX("pgsql.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_links, zend_pgsql_globals, pgsql_globals, display_link_numbers) -STD_PHP_INI_BOOLEAN( "pgsql.auto_reset_persistent", "0", PHP_INI_SYSTEM, OnUpdateBool, auto_reset_persistent, zend_pgsql_globals, pgsql_globals) +STD_PHP_INI_BOOLEAN( "pgsql.auto_reset_persistent", "0", PHP_INI_SYSTEM, OnUpdateLong, auto_reset_persistent, zend_pgsql_globals, pgsql_globals) STD_PHP_INI_BOOLEAN( "pgsql.ignore_notice", "0", PHP_INI_ALL, OnUpdateBool, ignore_notices, zend_pgsql_globals, pgsql_globals) STD_PHP_INI_BOOLEAN( "pgsql.log_notice", "0", PHP_INI_ALL, OnUpdateBool, log_notices, zend_pgsql_globals, pgsql_globals) PHP_INI_END() diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index f297f91b3ec..a3a8cd95c2a 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -184,9 +184,10 @@ static const php_stream_ops php_stream_pgsql_fd_ops = { ZEND_BEGIN_MODULE_GLOBALS(pgsql) zend_long num_links,num_persistent; zend_long max_links,max_persistent; - zend_long allow_persistent; + bool allow_persistent; + int ignore_notices; zend_long auto_reset_persistent; - int ignore_notices,log_notices; + int log_notices; zend_object *default_link; /* default link when connection is omitted */ HashTable field_oids; HashTable table_oids;