Skip to content

Commit 615ce0c

Browse files
bjoriderickr
authored andcommitted
PHPC-390: php.ini updates
1 parent 03ebdc6 commit 615ce0c

File tree

3 files changed

+36
-19
lines changed

3 files changed

+36
-19
lines changed

phongo_compat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147

148148
#if PHP_VERSION_ID >= 70000
149149
# define phongo_char zend_string
150-
# define phongo_char_pdup(str) zend_string_copy(filename)->val
150+
# define phongo_char_pdup(str) pestrdup(filename->val, 1)
151151
# define phongo_char_free(str) zend_string_release(str)
152152
# define phongo_str(str) str->val
153153
# define phongo_create_object_retval zend_object*

php_phongo.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
#define PHONGO_STREAM_BUFFER_SIZE 4096
7878

7979
ZEND_DECLARE_MODULE_GLOBALS(mongodb)
80+
#if PHP_VERSION_ID >= 70000
81+
#if defined(ZTS) && defined(COMPILE_DL_MONGODB)
82+
ZEND_TSRMLS_CACHE_DEFINE();
83+
#endif
84+
#endif
8085

8186
/* {{{ phongo_std_object_handlers */
8287
zend_object_handlers phongo_std_object_handlers;
@@ -1747,7 +1752,9 @@ static bool php_phongo_apply_wc_options_to_client(mongoc_client_t *client, bson_
17471752

17481753
static mongoc_client_t *php_phongo_make_mongo_client(const mongoc_uri_t *uri, zval *driverOptions TSRMLS_DC) /* {{{ */
17491754
{
1750-
#ifdef PHONGO_TODO_INI
1755+
#if PHP_VERSION_ID >= 70000
1756+
zval *tmp;
1757+
#else
17511758
zval **tmp;
17521759
#endif
17531760
php_stream_context *ctx = NULL;
@@ -1756,12 +1763,15 @@ static mongoc_client_t *php_phongo_make_mongo_client(const mongoc_uri_t *uri, zv
17561763

17571764
ENTRY;
17581765

1759-
#ifndef PHONGO_TODO_INI
1760-
(void)driverOptions;
1761-
#endif
1762-
1763-
1764-
#ifdef PHONGO_TODO_INI
1766+
#if PHP_VERSION_ID >= 70000
1767+
if (driverOptions && (tmp = zend_hash_str_find(Z_ARRVAL_P(driverOptions), "debug", sizeof("debug")-1)) != NULL) {
1768+
zend_string *key = zend_string_init(PHONGO_DEBUG_INI, sizeof(PHONGO_DEBUG_INI)-1, 0);
1769+
zend_string *value_str = zval_get_string(tmp);
1770+
zend_alter_ini_entry_ex(key, value_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0);
1771+
zend_string_release(key);
1772+
zend_string_release(value_str);
1773+
}
1774+
#else
17651775
if (driverOptions && zend_hash_find(Z_ARRVAL_P(driverOptions), "debug", strlen("debug") + 1, (void**)&tmp) == SUCCESS) {
17661776
convert_to_string(*tmp);
17671777

@@ -2221,11 +2231,13 @@ ZEND_INI_MH(OnUpdateDebug)
22212231

22222232

22232233
/* {{{ INI entries */
2224-
#ifdef PHONGO_TODO_INI
22252234
PHP_INI_BEGIN()
2235+
#if PHP_VERSION_ID >= 70000
2236+
STD_PHP_INI_ENTRY(PHONGO_DEBUG_INI, PHONGO_DEBUG_INI_DEFAULT, PHP_INI_ALL, OnUpdateDebug, debug, zend_mongodb_globals, mongodb_globals)
2237+
#else
22262238
{ 0, PHP_INI_ALL, (char *)PHONGO_DEBUG_INI, sizeof(PHONGO_DEBUG_INI), OnUpdateDebug, (void *) XtOffsetOf(zend_mongodb_globals, debug), (void *) &mglo, NULL, (char *)PHONGO_DEBUG_INI_DEFAULT, sizeof(PHONGO_DEBUG_INI_DEFAULT)-1, NULL, 0, 0, 0, NULL },
2227-
PHP_INI_END()
22282239
#endif
2240+
PHP_INI_END()
22292241
/* }}} */
22302242

22312243
/* {{{ PHP_GINIT_FUNCTION */
@@ -2237,6 +2249,11 @@ PHP_GINIT_FUNCTION(mongodb)
22372249
php_phongo_realloc,
22382250
php_phongo_free,
22392251
};
2252+
#if PHP_VERSION_ID >= 70000
2253+
#if defined(COMPILE_DL_MONGODB) && defined(ZTS)
2254+
ZEND_TSRMLS_CACHE_UPDATE();
2255+
#endif
2256+
#endif
22402257
mongodb_globals->debug_fd = NULL;
22412258
mongodb_globals->bsonMemVTable = bsonMemVTable;
22422259

@@ -2249,9 +2266,7 @@ PHP_MINIT_FUNCTION(mongodb)
22492266
(void)type; /* We don't care if we are loaded via dl() or extension= */
22502267

22512268

2252-
#ifdef PHONGO_TODO_INI
22532269
REGISTER_INI_ENTRIES();
2254-
#endif
22552270

22562271
/* Initialize libmongoc */
22572272
mongoc_init();
@@ -2328,9 +2343,7 @@ PHP_MSHUTDOWN_FUNCTION(mongodb)
23282343
/* Cleanup after libmongoc */
23292344
mongoc_cleanup();
23302345

2331-
#ifdef PHONGO_TODO_INI
23322346
UNREGISTER_INI_ENTRIES();
2333-
#endif
23342347

23352348
return SUCCESS;
23362349
}

php_phongo.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@ ZEND_BEGIN_MODULE_GLOBALS(mongodb)
5454
bson_mem_vtable_t bsonMemVTable;
5555
ZEND_END_MODULE_GLOBALS(mongodb)
5656

57-
#ifdef ZTS
58-
# define MONGODB_G(v) TSRMG(mongodb_globals_id, zend_mongodb_globals *, v)
59-
# define mglo mongodb_globals_id
57+
#if PHP_VERSION_ID >= 70000
58+
# define MONGODB_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(mongodb, v)
6059
#else
61-
# define MONGODB_G(v) (mongodb_globals.v)
62-
# define mglo mongodb_globals
60+
# ifdef ZTS
61+
# define MONGODB_G(v) TSRMG(mongodb_globals_id, zend_mongodb_globals *, v)
62+
# define mglo mongodb_globals_id
63+
# else
64+
# define MONGODB_G(v) (mongodb_globals.v)
65+
# define mglo mongodb_globals
66+
# endif
6367
#endif
6468

6569
#define PHONGO_WRITE_CONCERN_W_MAJORITY "majority"

0 commit comments

Comments
 (0)