Skip to content

Commit 2c4ed2a

Browse files
committed
Use separate vars when fetching debug and context from driverOptions
1 parent 1675a45 commit 2c4ed2a

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

php_phongo.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,9 +1906,11 @@ static bool php_phongo_apply_wc_options_to_client(mongoc_client_t *client, bson_
19061906
static mongoc_client_t *php_phongo_make_mongo_client(php_phongo_manager_t *manager, const mongoc_uri_t *uri, zval *driverOptions TSRMLS_DC) /* {{{ */
19071907
{
19081908
#if PHP_VERSION_ID >= 70000
1909-
zval *tmp;
1909+
zval *zdebug = NULL;
1910+
zval *zcontext = NULL;
19101911
#else
1911-
zval **tmp;
1912+
zval **zdebug = NULL;
1913+
zval **zcontext = NULL;
19121914
#endif
19131915
php_stream_context *ctx = NULL;
19141916
const char *mech, *mongoc_version, *bson_version;
@@ -1917,27 +1919,27 @@ static mongoc_client_t *php_phongo_make_mongo_client(php_phongo_manager_t *manag
19171919
ENTRY;
19181920

19191921
#if PHP_VERSION_ID >= 70000
1920-
if (driverOptions && (tmp = zend_hash_str_find(Z_ARRVAL_P(driverOptions), "debug", sizeof("debug")-1)) != NULL) {
1922+
if (driverOptions && (zdebug = zend_hash_str_find(Z_ARRVAL_P(driverOptions), "debug", sizeof("debug")-1)) != NULL) {
19211923
zend_string *key = zend_string_init(PHONGO_DEBUG_INI, sizeof(PHONGO_DEBUG_INI)-1, 0);
1922-
zend_string *value_str = zval_get_string(tmp);
1924+
zend_string *value_str = zval_get_string(zdebug);
19231925
zend_alter_ini_entry_ex(key, value_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0);
19241926
zend_string_release(key);
19251927
zend_string_release(value_str);
19261928
}
19271929
#else
1928-
if (driverOptions && zend_hash_find(Z_ARRVAL_P(driverOptions), "debug", strlen("debug") + 1, (void**)&tmp) == SUCCESS) {
1929-
convert_to_string(*tmp);
1930+
if (driverOptions && zend_hash_find(Z_ARRVAL_P(driverOptions), "debug", strlen("debug") + 1, (void**)&zdebug) == SUCCESS) {
1931+
convert_to_string(*zdebug);
19301932

1931-
zend_alter_ini_entry_ex((char *)PHONGO_DEBUG_INI, sizeof(PHONGO_DEBUG_INI), Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
1933+
zend_alter_ini_entry_ex((char *)PHONGO_DEBUG_INI, sizeof(PHONGO_DEBUG_INI), Z_STRVAL_PP(zdebug), Z_STRLEN_PP(zdebug), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
19321934
}
19331935
#endif
19341936

19351937
#if PHP_VERSION_ID >= 70000
1936-
if (driverOptions && (tmp = zend_hash_str_find(Z_ARRVAL_P(driverOptions), "context", sizeof("context")-1)) != NULL) {
1937-
ctx = php_stream_context_from_zval(tmp, 0);
1938+
if (driverOptions && (zcontext = zend_hash_str_find(Z_ARRVAL_P(driverOptions), "context", sizeof("context")-1)) != NULL) {
1939+
ctx = php_stream_context_from_zval(zcontext, 0);
19381940
#else
1939-
if (driverOptions && zend_hash_find(Z_ARRVAL_P(driverOptions), "context", strlen("context") + 1, (void**)&tmp) == SUCCESS) {
1940-
ctx = php_stream_context_from_zval(*tmp, 0);
1941+
if (driverOptions && zend_hash_find(Z_ARRVAL_P(driverOptions), "context", strlen("context") + 1, (void**)&zcontext) == SUCCESS) {
1942+
ctx = php_stream_context_from_zval(*zcontext, 0);
19411943
#endif
19421944
} else {
19431945
ctx = FG(default_context) ? FG(default_context) : php_stream_context_alloc(TSRMLS_C);

0 commit comments

Comments
 (0)